We all know that watching free movies can not give you some ads, quoting other Web site video to their site is OK, but ads can not be less, how to advertise, look down!
The usual way to get the player address is through:
You can also click the right button to see the source code, and find its address.
That is
1:file_get_contents/curl-page HTML
2: Regular Analysis video address
Disadvantages:
1: Slow, HTML page larger, there is a lot of information is "impurity" information
2: If the page is revised, the collection rules may fail.
So, we don't use that method, using the following
Using the Potato API to get XML information
1:xml is pure data, content is small, get fast
2: Pure data, such as title, length and so on, these will not change. Hard to fail.
At present, the major websites have their own open interface, application programing interface, application interface
Using the website's API, you can search for information
such as watercress's book information, potato video information .....
How to get the API interface:
Baidu Search Potato API, register application, get two important values
How to use the video according to the API documentation
<?php/*** $key = 1f3918053ff6bc04***/error_reporting (E_all & ~e_notice), if ($tudou = $_post[' Tudou ']) {$ITEMC Ode = basename ($tudou); $key = ' 1F3918053FF6BC04 '; $api = ' http://api.tudou.com/v3/gw?method=item.info.get&appKey= '. $key. ' &format=xml '. ' &itemcodes= '. $itemcode; Echo $api; /* echo $api, get an XML document, content is the title of the video, length, cover, and so on the next thing we want to do is to use PHP to parse the XML node information out of the Knowledge Point: DOMDocument class to parse the current, we do not XML parsing, but directly using string manipulation to get the address */$source = file_get_contents ($API); $start = Strpos ($source, '
Refer to it self-learning network.
XML get web site video