Home >Backend Development >PHP Tutorial >Also talk about intercepting homepage news - Example_PHP Tutorial

Also talk about intercepting homepage news - Example_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 16:03:09979browse

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>", "", $printing[1]);
$printing[1] = str_replace("", "", $printing[1]);
$printing[1] = str_replace(" class=sbody", "", $printing[1]);
$printing[1] = str_replace("
$content = $printing[1];
$content = explode("-", $content);

$headlines = sizeof($content);

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

print "News".($i+1) .") : $content[$i]
";//The exciting moment has arrived! It shows!

}

?>


Debug passed under php3/php4 apache.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316289.htmlTechArticleInterception of yahoo.com.cn news [experimental only] There are many programs to intercept homepage news, but they are not successful. . There are two working principles. One is to use what some websites call backen...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn