java获取链接数据
package com.dongao.test;
import com.alibaba.fastjson.JSON;
import com.dongao.project.common.util.HttpPostUtil;
import java.util.*;
/**
* @ClassName:MainTest
* @author:test
* @date 2021/7/5 17:34
*/
public class MainTest {
public static void main(String[] args) {
String url = "请求链接";
StringBuffer sb = new StringBuffer();
Set set = new HashSet();
Map map = new HashMap(4);
map.put("line","1");
map.put("levelnum","0");
for (int i = 1; i < 194; i++) {
map.put("cpage",String.valueOf(i));
String post = HttpPostUtil.post(url, map);
Map maps = JSON.parseObject(post, Map.class);
List<Map> chileds = (List<Map>) maps.get("chiled");
for (Map m : chileds) {
String drugname = (String) m.get("DRUGNAME");
if (set.contains(drugname)) {
}else {
set.add(drugname);
sb.append(m.get("DRUGNAME"));
sb.append(",");
}
}
}
System.out.println(sb.toString());
}
}
注:仅供个人自测使用–日常记录