Use PHP to extract the FLASH address in the video website page code

  • 2020-03-31 20:36:02
  • OfStack

I then implemented this in PHP, and I found it a joy to do this work in PHP! With its powerful HTML page handlers and regular expressions, you can do this in just a few lines of code.
Post the key code:
 
<?php 
//Get flash address in 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 ); 
?> 

So if we save this file as test.php, then we just run test.php, right? Youku video url can be resolved out of the FLASH address.
The idea is very simple, is to look at the youku video page HTML code in the key FLASH address section of the characteristics. Just look at a random web page. For example, we can see this paragraph:
< 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.

Related articles: