Home > Article > Backend Development > Also talk about intercepting homepage news - example
Intercepting yahoo.com.cn news [experimental only]
There are many programs for intercepting homepage news, but they are not successful.
Their working principles are nothing more than two. One is to use the back-end database interface called backend by some websites, and the other is to intercept directly based on the html code. This program uses the latter. It should be said that the fault tolerance performance is relatively good.
$open = fopen("http://www.yahoo.com.cn/index.html", "r");//Webpage address
$read = fread($open, 15000);
fclose($open);
$search = eregi("(.*)", $read, $printing );//Intercept a piece of source code, it is best to analyze the source code first
//Start extracting the remaining source code below
$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("
The above has introduced the example of intercepting homepage news - examples, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.