Use PHP to extract the FLASH Address Code from the video website page

Source: Internet
Author: User
In the past few days, you need to write a program to extract the FLASH Address of a video website address, such as an address of Youku.

In the past few days, you need to write a program to extract the FLASH Address of a video website address, such as an address of Youku.

Then I implemented this function using PHP. I think it is a pleasure to use PHP to do this job! 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.