//////////////////////php代码部分
public function snoopy()
{require_once APP_PATH . 'Home/Model/Snoopy.class.php';
//include 'Home/Model/Snoopy.class.php'; //加载Snoopy类
$snoopy = new \Snoopy(); //实例化一个对象
$sourceURL = "http://www.ithome.com/"; //要抓取的网页
$snoopy->fetch($sourceURL);//获取所有内容
$conn = $snoopy->results;
//print_r(utf8_encode($a));
$c 'utf-8');
$pregContent = "/(.*?)/iU";
preg_match_all($pregContent, $content, $contentArray);//匹配内容到arr数组
$connEnd = $contentArray[1][0];
// $kaishi="lst lst-1 new-list";
// $jieshu="page_nav";
// $kaishizishu = stripos($content,$kaishi);
// $jieshuzishu = stripos($content,$jieshu);
// $connEnd = substr($content,$kaishizishu+ strlen($kaishi), $jieshuzishu - ($kaishizishu + strlen($kaishi)));
$connEnd = str_replace("
- ","",$connEnd);
$connEnd = str_replace("
- ","",$connEnd);
{$vo[2][0]}
$liArry = explode("",$connEnd);
$pattern = "/(.*?)/i";
$data_array = array();
foreach($liArry as $item){
$_itemArr = array();
preg_match_all($pattern, $item, $_itemArr);//匹配内容到arr数组
array_push($data_array,$_itemArr);
}
// print_r($data_array);
// exit();
$this->assign("dateList",$data_array);
$this->assign("itempageUrl",U('Index/itemPage'));
$this->display();
}
///////////////////////////html代码部分
IT之家
以上就介绍了代码采集 snoopy,包括了snoopy方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
免责声明:本站内容仅用于学习参考,信息和图片素材来源于互联网,如内容侵权与违规,请联系我们进行删除,我们将在三个工作日内处理。联系邮箱:chuangshanghai#qq.com(把#换成@)