JavaQQ头像抓取
public static void main(String[] args) {
ExecutorService executorService = Executors.newFixedThreadPool(20);
long qq = 3022450446L;
for (int i = 0; i < 10; i++) {
long tempQQ = qq + i;
executorService.submit(() -> {
HttpResponse httpResponse = HttpRequest.get("http://q2.qlogo.cn/headimg_dl?dst_uin=" + tempQQ + "&spec=640").execute();
if (httpResponse.getStatus() == 200) {
String contentType = httpResponse.header("Content-Type");
String suffix = contentType.substring(contentType.indexOf("/") + 1);
httpResponse.writeBody(new File(tempQQ + "." + suffix));
}
});
}
executorService.shutdown();
}
Maven
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.7</version>
</dependency>