Java爬虫爬取王者荣耀皮肤

皮肤点赞拿走不谢:
链接:https://pan.baidu.com/s/1nTt79LZlbSPigXBIlLnucw
提取码:5uev
链接被举报了,附上源码

package com.hdy.cn.test.crawler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hdy.cn.test.FileUtil;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * Created by dong on 2021-4-11.
 */
@Service
public class CrawlerTest2 {
        public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("https://pvp.qq.com/web201605/js/herolist.json")
                .get()
                .addHeader("Content-Type", "text/xml;charset=UTF-8")
                .addHeader("Cache-Control", "no-cache")
                .addHeader("Postman-Token", "5117fe2a-dc13-4f8d-9647-a9c25c5613c2")
                .build();
        Response response = null;
        String string = null;
        try {
            response = client.newCall(request).execute();
            ResponseBody body = response.body();
            string = body.string();
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONArray jsonArray = (JSONArray) JSONObject.parse(string);
        int j = 0;
        for (Object jsonObject : jsonArray) {
            j++;
            JSONObject json = (JSONObject) jsonObject;
            String ename = String.valueOf(json.get("ename"));
            for (int i = 1; i <= 20; i++) {
                String pfUrl = "http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/";
                pfUrl += ename + "/" + ename + "-bigskin-" + i + ".jpg";
                String title = String.valueOf(json.get("title"));
                String cname = String.valueOf(json.get("cname"));
                System.out.println("第" + j + "英雄" + cname + "," + title + i + ": " + pfUrl);
                try {
                    FileUtil.download(pfUrl, title + i + ".jpg", "d:\\image\\" + cname);
                } catch (Exception e) {
                    break;
                }
            }
        }

    }

}
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值