yujian
2019-05-29 85fa0a9ed1f6cec968ca8e7ee80db872eb22c9cb
Merge remote-tracking branch 'origin/master'
2个文件已修改
71 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/env-pro-by/mongo.properties 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -366,64 +366,25 @@
     * 
     * @return
     */
    public static List<TaoBaoGoodsBrief> getDingDongQiang() {
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
    public static List<DaTaoKeDetail> getDingDongQiang() {
        List<DaTaoKeDetail> goodsList = new ArrayList<>();
        try {
            Document doc = Jsoup.connect("http://dataoke.yeshitv.com/index.php?r=ddq/wap")
            Document doc = Jsoup.connect("http://www.dataoke.com/ddq")
                    .userAgent(
                            "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Mobile Safari/537.36")
                    .get();
            Elements els = doc.getElementsByTag("script");
            for (int i = 0; i < els.size(); i++) {
                Element item = els.get(i);
                if (item.toString().length() > 5000) {
                    String html = item.html();
                    int endIndex = html.indexOf("} ;") + 1;
                    int startIndex = html.indexOf("data =");
                    String json = html.substring(startIndex + "data =".length(), endIndex).trim();
                    JSONObject root = JSONObject.fromObject(json);
                    Iterator<String> keys = root.keySet().iterator();
                    List<String> ids = new ArrayList<>();
                    while (keys.hasNext()) {
                        String key = keys.next();
                        JSONArray array = root.optJSONObject(key).optJSONArray("list");
                        for (int j = 0; j < array.size(); j++) {
                            if (TimeUtil.convertToTimeTemp(array.optJSONObject(j).optString("paiqi"),
                                    "yyyy-MM-dd HH:mm:ss") < System.currentTimeMillis())
                                ids.add(array.optJSONObject(j).optString("id"));
            Elements items = doc.getElementsByClass("main").get(0).getElementsByClass("clearfix").get(0)
                    .getElementsByTag("li");
            for (int i = 0; i < items.size(); i++) {
                DaTaoKeDetail detail = new DaTaoKeDetail();
                String id = items.get(i).getElementsByTag("a").get(0).attr("href").split("\\?")[1].replace("id=", "");
                detail.setId(Long.parseLong(id));
                goodsList.add(detail);
                        }
                    }
                    Collections.shuffle(ids);
                    List<Long> goodsIdList = new ArrayList<>();
                    ids.parallelStream().forEach(id -> {
                        try {
                            long auctionId = getAuctionId(Long.parseLong(id));
                            goodsIdList.add(auctionId);
                        } catch (Exception e) {
                        }
                    });
                    goodsIdList.parallelStream().forEach(goods -> {
                        try {
                            TaoBaoGoodsBrief gds = TaoKeApiUtil.searchGoodsDetail(goods);
                            if (gds != null)
                                goodsList.add(gds);
                        } catch (Exception e) {
                        }
                    });
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return goodsList;
    }
    //
@@ -536,19 +497,21 @@
        // 标题+券后价+包邮+描述
        String desc = detail.getdTitle();
        desc += "\n";
        desc += String.format("券后价%s【%s元】包邮秒杀 ",Math.random()>0.5?"💰":"", MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
        desc += String.format("券后价%s【%s元】包邮秒杀 ", Math.random() > 0.5 ? "💰" : "",
                MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
                + (Math.random()>0.5?getRandomCommonEmoji():"");
        desc += "\n";
//        desc += detail.getIntroduce();
        String introduce = detail.getIntroduce().replace(",", ",").replace("。", ",").replace("!", ",")
                .replace(",", ",");
        String introduce = detail.getIntroduce().replace(",", ",").replace("。", ",").replace("!", ",").replace(",",
                ",");
        introduce=introduce.replace(",,,", ",").replace(",,", ",");
        
        String[] sts = introduce.split(",");
        introduce = "";
        for (int i = 0; i < sts.length; i++) {
            if (i % 2 == 1) {// 需要换行
                introduce += sts[i] + (Math.random()>0.5?getRandomCommonEmoji():i==sts.length-1?"":",") + "\n";
                introduce += sts[i] + (Math.random() > 0.5 ? getRandomCommonEmoji() : i == sts.length - 1 ? "" : ",")
                        + "\n";
            } else
                introduce += sts[i] + (Math.random()>0.5?getRandomCommonEmoji():i==sts.length-1?"":",");
        }
fanli/src/main/resource/env-pro-by/mongo.properties
@@ -2,7 +2,7 @@
mongo.port=27017
#上线环境
mongo.host=127.0.0.1
mongo.host=193.112.35.168
mongo.username=yeshi
mongo.password=Yeshi2016@
mongo.connectionsPerHost=8