From 0588d6be74335f41c79a8d8e32dbd1c3d3e47fa3 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期三, 29 五月 2019 17:20:50 +0800
Subject: [PATCH] 精选库商品入库及更新调整 + 9k9类商品查询取消标签查询
---
fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java | 54 +++++++++---------------------------------------------
1 files changed, 9 insertions(+), 45 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java
index 34587f5..915fd06 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java
@@ -8,6 +8,7 @@
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.yeshi.utils.HttpUtil;
@@ -52,54 +53,17 @@
* @return
*/
public static List<String> getBrandIdList() {
- List<String> listId = null;
+ List<String> listId = new ArrayList<>();
try {
- Document doc = Jsoup.connect("http://www.dataoke.com/brandFeature").get();
- Elements els = doc.getElementsByTag("script");
- for (int i = 0; i < els.size(); i++) {
- if (els.get(i).html().contains("var brandData")) {
-
- JSONObject data = JSONObject
- .fromObject(els.get(i).html().replace("var brandData =", "").trim().split("};")[0] + "}");
- listId = convertList(data);
- break;
- }
+ Document doc = Jsoup.connect("http://www.dataoke.com/brandFilter?cid=0&sort=1&main=0").get();
+ Element root = doc.getElementsByClass("brand-list").get(0);
+ Elements items = root.getElementsByTag("a");
+ for (int i = 0; i < items.size(); i++) {
+ String id = items.get(i).attr("href").split("\\?")[1].replace("id=", "").trim();
+ listId.add(id);
}
-
} catch (Exception e) {
e.printStackTrace();
- }
- return listId;
- }
-
- public static List<String> convertList(JSONObject data) {
- List<String> listId = new ArrayList<String>();
-
- // 钀岃叮鏂扮敓鍔� 澶忔棩濂介鍏夋爮鐩�
- JSONArray arrayActs = data.optJSONObject("acts").optJSONArray("list");
- for (int i = 0; i < arrayActs.size(); i++) {
- JSONObject item = arrayActs.optJSONObject(i);
- listId.add(item.optString("brand_id"));
- }
-
- // 鐑帹鐖嗘
- JSONArray arrayPushs = data.optJSONObject("pushs").optJSONArray("list");
- for (int i = 0; i < arrayPushs.size(); i++) {
- JSONObject item = arrayPushs.optJSONObject(i);
- listId.add(item.optString("brand_id"));
- }
-
- // 鐑攢鍝佺墝姒�
- JSONArray arrayRanks = data.optJSONObject("ranks").optJSONArray("list");
- for (int i = 0; i < arrayRanks.size(); i++) {
- JSONObject item = arrayRanks.optJSONObject(i);
- // long id = item.optLong("id");
- // String title =item.optString("title");
- JSONArray goods = item.optJSONArray("goods");
- for (int j = 0; j < goods.size(); j++) {
- JSONObject good = goods.optJSONObject(j);
- listId.add(good.optString("brand_id"));
- }
}
return listId;
}
@@ -147,7 +111,7 @@
List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
JSONArray arrayGoods = data.optJSONArray("goods");
for (int i = 0; i < arrayGoods.size(); i++) {
- if (i > 3) {
+ if (i >= 2) {
break;
}
JSONObject itemGoods = arrayGoods.optJSONObject(i);
--
Gitblit v1.8.0