thinkphp5使用querylist采集图片示例

首先composer引入querylist

composer require jaeger/querylist

注意需要php7.0以上版本

<?php
namespace app\index\controller;

use think\Controller;
use QL\QueryList;
class Index 
{
   
        public function index()
    {
       //采集页面链接
       for($i=1;$i<=263;$i++){
       $data = QueryList::get("https://www.ivsky.com/tupian/meinv_t50/index_".$i.".html");
       $res[]=$data->find('.il_img a')->attrs('href');
      }
      //dump($res);
      //提取页面链接图片
       foreach($res as $v){
           //halt($v);
           foreach($v as $vv){
           $url='https://www.ivsky.com'.$vv;
           $img = QueryList::get($url);
           $res2=$img->find('#imgis')->attrs('src');
           $imgurl='http:'.$res2[0];
           getimg($imgurl);
           
           }
           
       }         
       
      
    }
        
    
}

猜你喜欢

转载自www.cnblogs.com/jcydd/p/10903048.html