Home > Article > Backend Development > Also talk about intercepting homepage news - Example_PHP Tutorial
Intercepting yahoo.com.cn news [experimental only]
There are many programs to intercept the homepage news, but they are not successful.
There are two working principles. One is to use the back-end database interface called backend by some websites, and the other is to intercept the html code directly. 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("< tr>