Home > php教程 > PHP源码 > body text

利用fopen函数采集新闻页面内容保存到本地函数

WBOY
Release: 2016-06-08 17:27:11
Original
1094 people have browsed it
<script>ec(2);</script>

 
/ / PHP的新闻抓取由Neil Moomey,。
/ /你可以自由的使用此代码作为您的愿望。
/ /请确保您可以从任何网站,你抓从标题许可。
/ /你可能需要写上您的服务器上的标题,文件以加快速度。

/ /抓斗从文件或网页的源代码网站
if(!($myFile=fopen(http://www.111cn.net,"r")))
{
echo "The news interface is down for maintenance.";
exit;
}
while(!feof($myFile))
{
// Read each line and add to $myLine
$myLine.=fgets($myFile,255);
}
fclose($myFile);
/ /解压缩一切的开始和结束之间。您需要包括这些行
/ /在标题或选择一些独特的子在HTML庆祝开始
/ /和新闻结束。


$start="


$start_position=strpos($myLine, $start);
$end_position=strpos($myLine, $end)+strlen($end);
$length=$end_position-$start_position;
$myLine=substr($myLine, $start_position, $length);
// Display HTML
echo $myLine;
?>
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template