当前位置:网站首页>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 
边栏推荐
- 763. dividing alphabetic intervals
- 阿里云函数计算服务一键搭建Z-Blog个人博客
- ABP framework Practice Series (I) - Introduction to persistence layer
- WPF value conversion
- [MySQL] MySQL export database
- [Flink] Flink source code analysis - creation of jobgraph in batch mode
- 软件调试测试的十大重要基本准则
- Optimization - multi objective planning
- 如何解决 Iterative 半监督训练 在 ASR 训练中难以落地的问题丨RTC Dev Meetup
- Quanergy欢迎Lori Sundberg出任首席人力资源官
猜你喜欢

判断两个集合的相同值 ||不同值

外包干了四年,人直接废了。。。

Detailed explanation of globalkey of flutter

MapReduce execution principle record

Flask入门

力扣 515. 在每个树行中找最大值

面了个字节拿25k出来的测试,算是真正见识到了基础的天花板

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

Intelligent manufacturing learning videos and books

ABP framework Practice Series (III) - domain layer in depth
随机推荐
Intelligent manufacturing learning videos and books
Analysis of updatechild principle of widget update mechanism of fluent
商城风格也可以很多变,DIY 了解一下
Use soapUI to access the corresponding ESB project
[QT] resource file import
【MySQL】 MySQL 导出数据库
bubble sort
Lua grammar explanation
Question brushing record day01
ASP. Net startup and running mechanism
What should I do if the 51 SCM board cannot find the device in keil
Mybatis的引入问题invalid
The stc-isp burning program for 51 single chip microcomputer always shows that "the target single chip microcomputer is being detected..." the cold start board does not respond
阿里云函数计算服务一键搭建Z-Blog个人博客
In 2022, what professional competitions can college students majoring in automation, electrical engineering and automation participate in?
Ten important basic principles of software debugging and testing
go语言泛型在IDE中语法报错
ipvs之ipvs0网卡
线程同步之条件变量
Spark - understand parquet