Also talk about intercepting homepage news-example _ PHP Tutorial

Source: Internet
Author: User
Let's also talk about the homepage news-example. The interception of yahoo.com.cn News [experiment only] has many programs for intercepting homepage news, but it cannot be successful. They work in two ways: one is to use some websites that call backen to intercept yahoo.com.cn news [for experiment only]

There are many programs for intercepting homepage news, but they cannot be successful.
They work in two ways: one is to use the backend database interface called backend for some websites, and the other is to intercept the html code with a hard voice. This program uses the latter. It should be said that the fault tolerance is better.
$ Open = fopen ("http://www.yahoo.com.cn/index.html", "r"); // web address
$ Read = fread ($ open, 15000 );
Fclose ($ open );

$ Search = eregi (" (.*) ", $ Read, $ printing); // extract a piece of source code. you 'd better analyze the source code first.
// Start to retrieve the source code
$ Printing [1] = str_replace ("href = \"/homer /? "," Href = \ "", $ printing [1]);
$ Printing [1] = str_replace ("href = \"/headlines/fullcoverage/"," href = \ "http://www.yahoo.com.cn/headlines/fullcoverage/", $ printing [1]);
$ Printing [1] = str_replace (""," ", $ Printing [1]);
$ Printing [1] = str_replace (""," ", $ Printing [1]);
$ Printing [1] = str_replace ("class = sbody", "", $ printing [1]);
$ Printing [1] = str_replace (""," ", $ Printing [1]);

$ Content = $ printing [1];
$ Content = explode ("-", $ content );

$ Headlines = sizeof ($ content );

For ($ I = 0; $ I <$ headlines; $ I ++ ){

Print "news". ($ I + 1). "): $ content [$ I]
"; // Exciting time! Shown!

}

?>


Debugging is successful under php3/php4 apache.

Ghost has many programs for intercepting homepage news, but it cannot be successful. They work in two ways. one is to use some websites called backen...

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.