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 Code You can achieve this function.
Paste the key code:
Copy code The Code is as follows: <? PHP
// Obtain the flash Address on the Youku page
Function get_flash_url ($ URL)
{
$ Lines = file ($ URL );
Foreach ($ lines as $ linenum => $ line ){
Preg_match_all ('| <input type = "text" id = "link2" value = "([^ <>] +)"/> |', $ line, $ result );
$ Swfurl = $ result [1] [0];
If (! Empty ($ swfurl ))
Return $ swfurl;
}
}
?>
<? PHP
$ 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:
<Div class = "item"> <SPAN class = "label"> flash Address: </span> <input type = "text" id = "link2" value = "http://player.youku.com/player.php/sid/XMTU1MzcxMzAw/v.swf"/>
Then, use the regular expression to match the address segment.