直接上代码:
//@SpringBootTest
class DemoApplicationTests {
@Test
void contextLoads() throws IOException {
RestTemplate restTemplate = new RestTemplate();//获取请求
ObjectMapper mapper = new ObjectMapper();//json格式转换
for (int i = 1; i <= 20271; i++) {//爬取页数循环
String forObject = restTemplate.getForObject("https:///?page="+i+"&size=100", String.class);//获取url请求的数据
System.out.println(forObject);
Map map = mapper.readValue(forObject, Map.class);//将Json字符串转为Map对象
Map result = (Map) map.get("result");//获取map中的result
List
评论列表(0条)