皮肤点赞拿走不谢:
链接: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;
}
}
}
}
}