| | |
| | | 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;
|
| | |
| | | *
|
| | | */
|
| | | public class DaTaoKeUtil {
|
| | |
|
| | | public static List<GoodsClass> goodsClasses;
|
| | | static {
|
| | | goodsClasses = new ArrayList<>();
|
| | | goodsClasses.add(new GoodsClass(4L, "居家日用"));
|
| | | goodsClasses.add(new GoodsClass(6L, "美食"));
|
| | | goodsClasses.add(new GoodsClass(2L, "母婴"));
|
| | | goodsClasses.add(new GoodsClass(3L, "美妆"));
|
| | | goodsClasses.add(new GoodsClass(1L, "女装"));
|
| | | goodsClasses.add(new GoodsClass(8L, "数码家电"));
|
| | | goodsClasses.add(new GoodsClass(7L, "文娱车品"));
|
| | | goodsClasses.add(new GoodsClass(10L, "内衣"));
|
| | | goodsClasses.add(new GoodsClass(14L, "家装家纺"));
|
| | | goodsClasses.add(new GoodsClass(5L, "鞋品"));
|
| | | goodsClasses.add(new GoodsClass(9L, "男装"));
|
| | | goodsClasses.add(new GoodsClass(12L, "配饰"));
|
| | | goodsClasses.add(new GoodsClass(13L, "户外运动"));
|
| | | goodsClasses.add(new GoodsClass(11L, "箱包"));
|
| | | }
|
| | |
|
| | | public static final String HOST = "http://dataoke.yeshitv.com";
|
| | |
|
| | |
| | | int[] ids = new int[] { 1, 9, 10, 2, 3, 4, 5, 6, 7, 8 };
|
| | | for (int i = 0; i < names.length; i++) {
|
| | | GoodsClass gc = new GoodsClass();
|
| | | gc.setId(Long.parseLong(ids[i]+""));
|
| | | gc.setId(Long.parseLong(ids[i] + ""));
|
| | | gc.setName(names[i]);
|
| | | list.add(gc);
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | }
|