[王者荣耀] 全部英雄和皮肤 无水印 原画壁纸

@Ta 10-01 14:02 233点击
写了个爬虫

https://www.aliyundrive.com/s/Fp5NuCkfySb



<?php

$time=microtime(true);

function p($str){
    echo $str.PHP_EOL;
}
require_once __DIR__."/vendor/autoload.php";
const workerDir=__DIR__.'/wangzheAll/';
use GuzzleHttp\Client;
$client = new Client([
    // Base URI is used with relative requests
    'base_uri' => 'https://pvp.qq.com',
    // You can set any number of default request options.
    'timeout'  => 2.0,
    'http_errors'=>false,
]);

//获取全部英雄
$heroResponse =$client->request('GET','/web201605/js/herolist.json' );
$heroJson=(string)$heroResponse->getBody();
$heroJsons=json_decode($heroJson,true);

$bigskinBase='http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/%s/%s-bigskin-%s.jpg';
foreach ($heroJsons as $hero){
    $id=$hero['ename']??'null';
    $cname=$hero['cname']??'null';
    $hero['count']=1;
    $hero['running']=true;
    //创建英雄文件夹

    $logoskinClient=new Client([
        // Base URI is used with relative requests
        'base_uri' =>sprintf('http://game.gtimg.cn/images/yxzj/img201606/heroimg/%s/%s.jpg',$id,$id),
        // You can set any number of default request options.
        'timeout'  => 10.0,
        'http_errors'=>false,
    ]);

    $logoskinResponse=$logoskinClient->request('get');
    file_put_contents(workerDir.$cname.'_logo.jpg',(string)$logoskinResponse->getBody());
    p('写入'.$cname.'英雄 logo');


    do{
        if(!$hero['running']){
            continue;
        }
        p('下载'.$cname.'英雄图片:'.$cname.'|第'.$hero['count'].'张');
        $bigskinClient=new Client([
            // Base URI is used with relative requests
            'base_uri' =>sprintf($bigskinBase,$id,$id,strval($hero['count'])),
            // You can set any number of default request options.
            'timeout'  => 10.0,
            'http_errors'=>false,
        ]);

        $bigskinResponse=$bigskinClient->request('get');
        if($bigskinResponse->getStatusCode()==200){
            file_put_contents(workerDir.$cname.'_'.$hero['count'].'.jpg',(string)$bigskinResponse->getBody());
            $hero['count']++;
            continue;
        }
        p('下载'.$cname.'英雄图片:'.$cname.'|完毕 一共'.$hero['count']);
        $hero['running']=false;

    }while($hero['running']);

}
echo '爬虫完成|';
echo round(microtime(true)-$time,2).'秒'.PHP_EOL;
//echo $heroResponse->getStatusCode();



回复列表(0)
帖子没有回复
添加新回复
回复需要登录

[聊天-文件上传] 希望自己长胖胖:MT管理器虽然好用,但是没有好像官网,百度下载或应用市场下载都是踩雷!