thinkphp5使用querylist採集圖片示例

首先composer引入querylistphp

composer require jaeger/querylist

注意須要php7.0以上版本html

<?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);
           
           }
           
       }         
       
      
    }
        
    
}
相關文章
相關標籤/搜索