快乐每一天

自己选择的路,跪着也要走下去...

利用ThinkPHP框架 抓取插件querylist 抓取妹子图首页数据跟详情页码

抓取工具地址:https://querylist.cc/

    public function homepage(){
        $url='https://www.mzitu.com';
        $rules=[
            'detail'=>['#pins>li>a','href'],
            'face'=>['#pins>li>a>img','data-original'],
            'alt'=>['#pins>li>a>img','alt'],
        ];
        $data = QueryList::get($url)->rules($rules)->query()->getData();

        $rt=$data->map(function($item){
            $item['count'] = $this->detail($item['detail']);
            return $item;
        })->all();

        echo '<pre>';
        var_dump($rt);
        echo '</pre>';
    }

    /*获取详情页数*/
    public function detail($url='https://www.mzitu.com/178724'){
        $rules=[
            'pagenavi'=>['.pagenavi','text']
        ];
        $rt = QueryList::get($url,[
            'headers'=>[
                'Referer'=>$url,
            ]
        ])
        ->rules($rules)->query()->getData()->all();
        return $this->cut('…','下一页',$rt[0]['pagenavi']);
    }

    //截取指定两个字符之间的字符串
    public function cut($begin,$end,$str){
        $b = mb_strpos($str,$begin) + mb_strlen($begin);
        $e = mb_strpos($str,$end) - $b;
        return mb_substr($str,$b,$e);
    }

数据展示效果:

array(24) {
  [0]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178724"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/178724_05a31_236.jpg"
    ["alt"]=>
    string(79) "美貌与身材兼具 黑丝美女周于希性感翘臀浑圆饱满紧致诱人"
    ["count"]=>
    string(2) "42"
  }
  [1]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178809"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/178809_05b03_236.jpg"
    ["alt"]=>
    string(67) "肥美尤物王婉悠血滴子内衣写真 暗黑魅惑嗜血销魂"
    ["count"]=>
    string(2) "41"
  }
  [2]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178630"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/178630_04b37_236.jpg"
    ["alt"]=>
    string(64) "头条女神笑笑软萌可爱又豪放 撩衣挤胸作风大胆"
    ["count"]=>
    string(2) "40"
  }
  [3]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/183163"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/183163_05b27_236.jpg"
    ["alt"]=>
    string(76) "人间尤物奶瓶土肥圆无圣光人体写真 高跟美腿魅力无法挡"
    ["count"]=>
    string(2) "46"
  }
  [4]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/182255"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/182255_29b20_236.jpg"
    ["alt"]=>
    string(66) "御姐PK小可爱 性感模特韩恩熙姐妹花诱惑再次上演"
    ["count"]=>
    string(2) "47"
  }
  [5]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/182852"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/182852_03b24_236.jpg"
    ["alt"]=>
    string(73) "满足你对老师的幻想 女神许诺Sabrina教师OL制服知性迷人"
    ["count"]=>
    string(2) "44"
  }
  [6]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/182994"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/182994_04b48_236.jpg"
    ["alt"]=>
    string(75) "玲珑美人Annie安妮性感写真 美乳翘臀下修长玉腿异常诱人"
    ["count"]=>
    string(2) "48"
  }
  [7]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/183043"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/183043_04c32_236.jpg"
    ["alt"]=>
    string(63) "美人醉语园中烟 女神芝芝Booty上演华丽丽的诱惑"
    ["count"]=>
    string(2) "65"
  }
  [8]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178473"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/178473_03a39_236.jpg"
    ["alt"]=>
    string(64) "乳沟好深 极品美女李可可性感美乳无法一手掌握"
    ["count"]=>
    string(2) "39"
  }
  [9]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178166"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/178166_30c11_236.jpg"
    ["alt"]=>
    string(67) "把自己当礼物 风情尤物Egg尤妮丝巨乳肥臀等你调教"
    ["count"]=>
    string(2) "41"
  }
  [10]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178380"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/178380_02b35_236.jpg"
    ["alt"]=>
    string(64) "丰满身材呼之欲出 蜜桃社美绪超级豪乳震惊网友"
    ["count"]=>
    string(2) "43"
  }
  [11]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178208"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/178208_01a04_236.jpg"
    ["alt"]=>
    string(64) "黑丝美人酥小白性感床照 惹火姿势尽显女王气质"
    ["count"]=>
    string(2) "37"
  }
  [12]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/173453"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/173453_26a21_236.jpg"
    ["alt"]=>
    string(66) "妩媚女神妲己Toxic薄纱湿身诱惑 喷血豪乳一目了然"
    ["count"]=>
    string(2) "41"
  }
  [13]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/175200"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/175200_12a02_236.jpg"
    ["alt"]=>
    string(68) "极品嫩妹徐cake性感写真秀美乳 一嘴酸奶画面好内涵"
    ["count"]=>
    string(2) "30"
  }
  [14]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/174906"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/05/174906_09a18_236.jpg"
    ["alt"]=>
    string(67) "绝色美女张雨萌裸体泡温泉 饱满酥胸令人热血上涌"
    ["count"]=>
    string(2) "40"
  }
  [15]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/182201"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/182201_29a14_236.jpg"
    ["alt"]=>
    string(69) "第一视角带剧情,性感美女王雨纯女仆幻想不容错过"
    ["count"]=>
    string(2) "53"
  }
  [16]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178424"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/178424_02c14_236.jpg"
    ["alt"]=>
    string(61) "性感模特月音瞳透视睡衣照 胸口敞开雪白诱人"
    ["count"]=>
    string(2) "48"
  }
  [17]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178335"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/178335_02a30_236.jpg"
    ["alt"]=>
    string(70) "爱蜜社兔女郎酥小白性感黑丝诱惑 火辣身材引人遐想"
    ["count"]=>
    string(2) "44"
  }
  [18]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/181701"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/181701_25a02_236.jpg"
    ["alt"]=>
    string(70) "尤物美女萌汉药baby迪拜旅拍,媚骨柔情如魔鬼般惹火"
    ["count"]=>
    string(2) "63"
  }
  [19]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178121"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/178121_30b04_236.jpg"
    ["alt"]=>
    string(69) "甜美脸蛋魔鬼身材 美少妇芝芝Booty美妙胴体双手难挡"
    ["count"]=>
    string(2) "44"
  }
  [20]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/176101"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/176101_18b25_236.jpg"
    ["alt"]=>
    string(71) "清纯可人不失性感 高冷妹子小姿2002五官精致气场强大"
    ["count"]=>
    string(2) "42"
  }
  [21]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/177562"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/177562_27a12_236.jpg"
    ["alt"]=>
    string(59) "宅男杀手小尤奈COS不知火舞 G奶晃动呼之欲出"
    ["count"]=>
    string(2) "40"
  }
  [22]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/178246"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/178246_01b20_236.jpg"
    ["alt"]=>
    string(73) "藏不住的波涛胸涌 大胸嫩模Evelyn艾莉雪乳风情有沟必火"
    ["count"]=>
    string(2) "40"
  }
  [23]=>
  array(4) {
    ["detail"]=>
    string(28) "https://www.mzitu.com/181907"
    ["face"]=>
    string(57) "https://i.meizitu.net/thumbs/2019/04/181907_25d04_236.jpg"
    ["alt"]=>
    string(64) "可清纯可妖艳 火辣御姐穆菲菲曼妙身姿完美绝伦"
    ["count"]=>
    string(2) "40"
  }
}
此文章共有条评论, 人参与 |Powerd By Angboo