// List<String> url1 = getUrl();
List<String> url1 = Lists.newArrayList("https://item.jd.com/100006803775.html");
for (int i = 0; i < url1.size(); i++) {
String skuId = Pattern.compile("[^0-9]").matcher(url1.get(i)).replaceAll("").trim();
// String info = Jsoup.connect("https://p.3.cn/prices/mgets?&pin=null&skuIds=" + skuId).ignoreContentType(true).execute().body();
String info = Jsoup.connect("https://pm.3.cn/prices/pcpmgets?callback=jQuery&skuids="+ skuId+"&origin=2").ignoreContentType(true).execute().body();
String replace = info.replace("[{", "").replace("}]", "");
String str1=replace.substring(0, replace.indexOf("\"op\":\""));
String str2=replace.substring(str1.length()+6, replace.length());
String price=str2.substring(0, str2.indexOf("\""));
System.out.println("id:"+id+" price:" + price);
// 这里一定要有一个等待时间,不能连续请求,不然京东有检测,会封ip,就查不了了
Thread.sleep(2000);
}
java爬取某东详情尚品属性
于 2022-08-09 15:57:48 首次发布