Home  >  Article  >  Backend Development  >  Use PHP to extract the code of FLASH address in the video website page_PHP tutorial

Use PHP to extract the code of FLASH address in the video website page_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:38:34925browse

Then I implemented this function using PHP. I think it is a pleasure to use PHP to do this work! Using the powerful HTML page processing functions and regular expressions it provides, you can accomplish this function in just a few lines of code.
Post the key code:

Copy the code The code is as follows:

//Get Flash address in 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 save this file as test.php, then we only need to run test.php? Youku video url to parse the FLASH address.
The idea is very simple, that is, first look at the characteristics of the key FLASH address in the HTML code of the Youku video page. Just find a web page, for example we can see this paragraph:
flash address:
Then use regular expressions to match the address segments Drop it and it’s OK.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321740.htmlTechArticleThen I used PHP to implement this function. I think it is a pleasure to use PHP to do this work! Using the powerful HTML page processing functions and regular expressions it provides, just a few lines of code...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn