| | |
| | | * @return
|
| | | */
|
| | |
|
| | | public static List<ImageInfo> getTBDetailImageWithSizev2(Long auctionId,ProxyIP ip) {
|
| | | public static List<ImageInfo> getTBDetailImageWithSizev2(Long auctionId, ProxyIP ip) {
|
| | | List<ImageInfo> imgList = new ArrayList<>();
|
| | | try {
|
| | | Map<String, String> headers = new HashMap<>();
|
| | | headers.put("User-Agent",
|
| | | "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");
|
| | | headers.put("Referer", "https://detail.tmall.com/item.htm?id=" + auctionId);
|
| | | String url = String.format("https://hws.m.taobao.com/cache/desc/5.0?id=" + auctionId);
|
| | | String result = HttpUtil.get(url,null,ip);
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | | LogHelper.test("代理IP:" + ip.getIp() + ":" + ip.getPort());
|
| | | String result = HttpUtil.get(url, headers, ip);
|
| | | LogHelper.test("返回内容:" + result);
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | |
|
| | | JSONArray array = data.optJSONObject("wdescContent").optJSONArray("pages");
|
| | | if (array != null) {
|
| | | String html = "";
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | String itemStr = array.optString(i).replace("<img", "<a").replace("</img>", "<a>");
|
| | | html += itemStr;
|
| | | }
|
| | | Document doc = Jsoup.parse(html);
|
| | | Elements items = doc.getElementsByTag("a");
|
| | | for (int i = 0; i < items.size(); i++) {
|
| | | ImageInfo img = new ImageInfo();
|
| | | Element item = items.get(i);
|
| | | if (StringUtil.isNullOrEmpty(item.ownText()))
|
| | | continue;
|
| | | if (!StringUtil.isNullOrEmpty(item.attr("size"))) {
|
| | | img.setWidth(Integer.parseInt(item.attr("size").split("x")[0]));
|
| | | img.setHeight(Integer.parseInt(item.attr("size").split("x")[1]));
|
| | | JSONArray array = data.optJSONObject("wdescContent").optJSONArray("pages");
|
| | | if (array != null) {
|
| | | String html = "";
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | String itemStr = array.optString(i).replace("<img", "<a").replace("</img>", "<a>");
|
| | | html += itemStr;
|
| | | }
|
| | | if (item.ownText().startsWith("http"))
|
| | | img.setPicture(item.ownText().trim());
|
| | | else
|
| | | img.setPicture("http:" + item.ownText().trim());
|
| | | imgList.add(img);
|
| | | Document doc = Jsoup.parse(html);
|
| | | Elements items = doc.getElementsByTag("a");
|
| | | for (int i = 0; i < items.size(); i++) {
|
| | | ImageInfo img = new ImageInfo();
|
| | | Element item = items.get(i);
|
| | | if (StringUtil.isNullOrEmpty(item.ownText()))
|
| | | continue;
|
| | | if (!StringUtil.isNullOrEmpty(item.attr("size"))) {
|
| | | img.setWidth(Integer.parseInt(item.attr("size").split("x")[0]));
|
| | | img.setHeight(Integer.parseInt(item.attr("size").split("x")[1]));
|
| | | }
|
| | | if (item.ownText().startsWith("http"))
|
| | | img.setPicture(item.ownText().trim());
|
| | | else
|
| | | img.setPicture("http:" + item.ownText().trim());
|
| | | imgList.add(img);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|