Home  >  Article  >  Backend Development  >  Also talk about intercepting homepage news - example

Also talk about intercepting homepage news - example

WBOY
WBOYOriginal
2016-07-29 08:33:591153browse

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

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.

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