>  기사  >  php教程  >  利用fopen函数采集新闻页面内容保存到本地函数

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

WBOY
WBOY원래의
2016-06-08 17:27:111056검색
<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;
?>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.