Also talk about intercepting home News-Sample _php Basics

Source: Internet
Author: User
Interception of yahoo.com.cn News [experiment only]

There are many programs to intercept the homepage news, but it will not succeed.
They work in two ways, one is to use some Web sites called backend backend database interface, and the other is hard sound based on HTML code interception. This procedure uses the latter. It should be said that fault-tolerant performance is relatively good.
?
$open = fopen ("http://www.yahoo.com.cn/index.html", "R");//web address
$read = Fread ($open, 15000);
Fclose ($open);

$search = Eregi ("<!--start in the News--> (. *) <!--end in the news-->", $read, $printing);//intercept a section of source code, it is best to analyze the source Code
The following starts 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 ("</td></tr><tr><td valign=top align=right>", "", $printing [1]);
$printing [1] = Str_replace ("</td><td>", "", $printing [1]);
$printing [1] = Str_replace ("Class=sbody", "" ", $printing [1]);
$printing [1] = Str_replace ("</small>", "", $printing [1]);

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

$headlines = sizeof ($content);

for ($i = 0; $i < $headlines; $i + +) {

Print "News". ($i + 1).): $content [$i]<br>]; The exciting time has come! It's showing up!

}

?>


In PHP3/PHP4 Apache debugging pass.

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.