利用fopen函数采集新闻页面内容保存到本地函数
<?php // PHP的新闻抓取由Neil Moomey,。 //你可以自由的使用此代码作为您的愿望。 //请确保您可以从任何网站,你抓从标题许可。 //你可能需要写上您的服务器上的标题,文件以加快速度。 //抓斗从文件或网页的源代码网站 if (!($myFile = fopen('http://www.phprm.com', "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 = "<hr align="; $end = "建立镜像"; $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;
本文地址:http://www.phprm.com/code/33105.html
转载随意,但请附上文章地址:-)