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);
           
           }
           
       }         
       
      
    }
        
    
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM