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]);
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.