Home  >  Article  >  Backend Development  >  QQ space flash address uses PHP to extract the code of the FLASH address in the video website page

QQ space flash address uses PHP to extract the code of the FLASH address in the video website page

WBOY
WBOYOriginal
2016-07-29 08:42:231042browse

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 the flash address in 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 save this file as test.php, then we only need to run test.php?Youku video url can be parsed to get 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 segment, and it's OK.

The above introduces the code of using qq space flash address to extract the FLASH address in the video website page using PHP, including the content of qq space flash address. I hope it will be helpful to friends who are interested in PHP tutorials.

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