Also talk about interception Homepage News-Example

Source: Internet
Author: User
Interception of yahoo.com.cn News [for experimentation only]
There are a lot of procedures for intercepting home news, but not successful.
They work in two ways, one is to use some web site called backend backend database interface, the other is the hard sound based on HTML code interception. The latter is used in this procedure. It should be said that fault-tolerant performance is better.
$open = fopen ("http://www.yahoo.com.cn/index.html", "R");//web address
$read = Fread ($open, 15000);
Fclose ($open);
$search = Eregi (" (.*) ", $read, $printing);//intercept a source code, it is best to analyze the source code first
The following begins to remove the Jong Yuyuan 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 is up! It's showing up!
}
?>
Debug through under Php3/php4 Apache.

The above describes also the interception of the home page news-examples, including the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.