| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoHead;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
| | | return couponList;
|
| | | }
|
| | |
|
| | | private static List<DaTaoKeDetail> parseCurrent(String url) {
|
| | | try {
|
| | | Document doc = Jsoup.connect(url)
|
| | | .userAgent(
|
| | | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36")
|
| | | .get();
|
| | | Elements items = doc.getElementsByClass("goods-list").get(0).getElementsByClass("goods-item");
|
| | | for (int i = 0; i < items.size(); i++) {
|
| | | Long id = Long.parseLong(items.get(i).attr("id").replace("goods-items_", ""));
|
| | | String currentSale = items.get(i).getElementsByClass("goods-item-content").get(0)
|
| | | .getElementsByClass("goods-info").get(0).getElementsByClass("tg-show").get(0)
|
| | | .getElementsByTag("b").get(0).text();
|
| | |
|
| | | System.out.println(id + "-" + currentSale);
|
| | |
|
| | | }
|
| | |
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // TODO 需要返回值
|
| | | return null;
|
| | | }
|
| | |
|
| | | // 获取实时榜单
|
| | | /**
|
| | | * 获取实时销量榜
|
| | | * |
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public static List<DaTaoKeDetail> getCurrentSalesRank(Long cid) {
|
| | | String url = null;
|
| | | if (cid == null)
|
| | | url = "http://www.dataoke.com/top_sell";
|
| | | else
|
| | | url = String.format("http://www.dataoke.com/top_sell?cid=%s&type=1", cid);
|
| | | return parseCurrent(url);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 全天销量榜
|
| | | * |
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public static List<DaTaoKeDetail> getCurrentDaySalesRank(Long cid) {
|
| | | String url = null;
|
| | | if (cid == null)
|
| | | url = "http://www.dataoke.com/top_all";
|
| | | else
|
| | | url = String.format("http://www.dataoke.com/top_all?cid=%s", cid);
|
| | | return parseCurrent(url);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取热推榜
|
| | | * |
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public static List<DaTaoKeDetail> getCurrentHotSalesRank() {
|
| | | String url = "http://www.dataoke.com/top_tui";
|
| | | return parseCurrent(url);
|
| | | }
|
| | |
|
| | | }
|