Use PHP to extract the FLASH address code from the video website page. Then I implemented this function using PHP. I think it is a pleasure to use PHP to do this job! Using its powerful HTML page processing functions and regular expressions, I realized this function with PHP after just a few generations. I think using PHP is a pleasure! With its powerful HTML page processing functions and regular expressions, you can use this function with just a few lines of code.
Paste the key code:
The code is as follows:
// Obtain the flash address on the Youku page
Function get_flash_url ($ url)
{
$ Lines = file ($ url );
Foreach ($ lines as $ linenum => $ line ){
Preg_match_all ('|| ', $ Line, $ result );
$ Swfurl = $ result [1] [0];
If (! Empty ($ swfurl ))
Return $ swfurl;
}
}
?>
$ Url = $ _ SERVER ["QUERY_STRING"];
$ Flashurl = get_flash_url ($ url );
Echo ($ flashurl );
?>
For example, if we store this file as test. php, we only need to run test. php? The url of Youku video can parse the FLASH address.
The idea is simple. First, let's look at the key FLASH address section in the HTML code of Youku's video webpage. Find a webpage. for example, we can see this section:
Flash address:
Then, use the regular expression to match the address segment.
Success! Use its powerful HTML page processing functions and regular expressions, just a few generations...