1. controllers:
$this->load->helper('date');
$this->load->helper('phpQuery');
//我是把phpQuery单文件放到helper里了2. view:
这里只是为了快速出产品,所以直接在VIEW里写的代码,请无视变量名。。。
find('.ptt td a');//从首页抓页面导航
//从页面导航开始获取页面内容
foreach($ps as $p)
{
echo '第'.$pn++.'页:attr("href").'"/>';
$imagesnow = phpQuery::newDocumentFile(pq($p)->attr("href"));
//单页内容
$images = $imagesnow->find('#gdt a');//抓取图片页列表
foreach($images as $image)
{
echo 'attr("href").'"/>';
$imagebigs = phpQuery::newDocumentFile(pq($image,$imagesnow)->attr("href"));
//获取单图片页地址
echo '
find('#i3 img')->attr('src').'">';//输出图片
ob_start();
readfile($imagebigs->find('#i3 img')->attr('src'));
$img = ob_get_contents();
ob_end_clean();
$filename='img/'.now().'.jpg';
$f=fopen($filename,'a');
fwrite($f,$img);
fclose($f);
}
}
?>