XML get web site video

Source: Internet
Author: User

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

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.