当前位置:网站首页>Using jsup to extract images from interfaces
Using jsup to extract images from interfaces
2022-06-26 04:04:00 【Lie down and count the stars】
Import dependence
<!-- Reptiles -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.2</version>
</dependency>
Use hutool Tool parsing json data
@GetMapping("/pachou")
@ApiOperation(" Reptiles ")
public String teamMessage() {
// s = HttpUtil.get("https://china.nba.cn/stats2/season/conferencestanding.json?");
s = HttpUtil.get("https://china.nba.cn/stats2/league/playerlist.json");
return s;
}
Extract and save to disk
@PostMapping("/addBatch2")
@ApiOperation(value = " Batch insert ")
public Result addBatch2(@RequestBody String str) throws IOException, InterruptedException {
JSONArray jsonArray = JSONArray.parseArray(str);
FileOutputStream outputStream =null;
// FileInputStream inputStream =null;
InputStream inputStream=null;
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString());
String playerProfile = jsonObject.getString("playerProfile");
String teamProfile = jsonObject.getString("teamProfile");
JSONObject object = JSONObject.parseObject(playerProfile);
JSONObject object2 = JSONObject.parseObject(teamProfile);
// System.out.println(object.getString("displayName"));
// System.out.println(object2.getString("city"));
String playerImg = object.getString("playerId");
String displayName = object.getString("displayName");
System.out.println(playerImg);
try {
String url="https://res.nba.cn/media/img/players/head/260x190/"+playerImg+".png";
URL imgsrcUrl = new URL(url);
URLConnection connection = imgsrcUrl.openConnection();
inputStream = connection.getInputStream();
String path="F:\\chenchao\\NBA\\"+displayName+".png";
outputStream = new FileOutputStream(path);
byte[] bytes = new byte[1024];
int len = 0;
while((len=inputStream.read(bytes))!=-1){
outputStream.write(bytes,0,len);
}
System.out.println(" Download complete ");
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
return Result.success();
}
effect 
边栏推荐
- Ieda suddenly cannot find compact middle packages
- [QT] resource file import
- Detailed explanation of widget construction process of fluent
- Yolov5 improvements: replace the backbone
- 解析JSON接口并批量插入到数据库中
- WPF 值转换
- R language and machine learning
- 使用Jsoup提取接口中的图片
- Restful API interface design standards and specifications
- Small record of neural network learning 71 - tensorflow2 deep learning with Google Lab
猜你喜欢

【Flink】Flink 批处理模式Map端数据聚合 NormalizedKeySorter

Part 4: drawing quadrilateral

Camera memory memory leak analysis (III)

Alibaba cloud function computing service one click to build Z-blog personal blog

神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习

DETR3D 多2d图片3D检测框架

Intelligent manufacturing learning videos and books

Force buckle 515 Find the maximum value in each tree row

2021 year end summary

判断两个集合的相同值 ||不同值
随机推荐
Binary search method
I/O 虚拟化技术 — VFIO
College C language final exam · multiple choice questions · summary notes of mistakes and difficulties
力扣79单词搜索
[从零开始学习FPGA编程-45]:视野篇 - 集成电路助力数字化时代高质量发展-2-市场预测
xml 解析bean工具类
User control custom DependencyProperty
[MySQL] MySQL export database
Oracle技术分享 oracle 19.14升级19.15
神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习
刷题记录Day01
Optimization - multi objective planning
What preparations should be made to develop an app from scratch
2022.6.23-----leetcode. thirty
VHDL design
[Flink] Flink source code analysis - creation of jobgraph in batch mode
1.基础关
Capture packets (Wireshark)
But the Internet began to have a new evolution and began to appear in a new state
169. 多数元素