| | |
| | |
|
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.nodes.Element;
|
| | | import org.jsoup.select.Elements;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | |
| | | * @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;
|
| | | }
|
| | |
| | | List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | JSONArray arrayGoods = data.optJSONArray("goods");
|
| | | for (int i = 0; i < arrayGoods.size(); i++) {
|
| | | if (i > 2) {
|
| | | if (i >= 2) {
|
| | | break;
|
| | | }
|
| | | JSONObject itemGoods = arrayGoods.optJSONObject(i);
|