| | |
| | | package com.yeshi.fanli.util.taobao;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLDecoder;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import javax.xml.parsers.DocumentBuilderFactory;
|
| | |
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.HttpException;
|
| | | import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
| | | import org.apache.commons.httpclient.methods.GetMethod;
|
| | | import org.apache.commons.httpclient.params.HttpMethodParams;
|
| | |
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.common.ImageInfo;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | tg.setTaoBaoQuanInfo(quanInfo);
|
| | | }
|
| | |
|
| | | BigDecimal proportion = taoBaoUtil.manageService.getFanLiRate();
|
| | | BigDecimal proportion = taoBaoUtil.manageService.getFanLiRate(UserLevelEnum.daRen);
|
| | | TaoBaoHongBaoInfo hongBaoInfo = new TaoBaoHongBaoInfo();
|
| | | String tkMktStatus = tb.getTkMktStatus();
|
| | | if ("1".equals(tkMktStatus)) {
|
| | |
| | | return tg;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief getTaoBaoGoodsBrief(String id) {
|
| | | Map<String, String> params = new HashMap<String, String>();
|
| | | params.put("q", String.format("http://item.taobao.com/item.htm?id=%s", id));
|
| | | params.put("_t", System.currentTimeMillis() + "");
|
| | | params.put("auctionTag", "");
|
| | | params.put("perPageSize", 40 + "");
|
| | | params.put("t", System.currentTimeMillis() + "");
|
| | | String result = TaoBaoHttpUtil.get(SEARCH_URL, params);
|
| | | result = result.replace("</span>", "").replace("<span class=H>", "");
|
| | | TaoBaoSearchResult presult = parseTaoBao(result);
|
| | | if (presult != null && presult.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | // TaoBaoGoodsBrief taoBaoGoodsBrief =
|
| | | // presult.getTaoBaoGoodsBriefs().get(0);
|
| | |
|
| | | return presult.getTaoBaoGoodsBriefs().get(0);
|
| | | } else
|
| | | return null;
|
| | | /**
|
| | | * 获取未参与推广的淘宝商品详情 @Title: getTaoBaoGoodsBrief @Description: @param
|
| | | * id @return TaoBaoGoodsBrief 包含(标题与图片) @throws
|
| | | */
|
| | | public static TaoBaoGoodsBrief getTaoBaoGoodsBriefNotInPub(Long id) {
|
| | | TaoBaoGoodsBrief tb = TaoBaoUtil.getTmallGoodsInfo(id + "");
|
| | | return tb;
|
| | | }
|
| | |
|
| | | public static List<String> getSuguestSearch(String key) {
|
| | |
| | | return taoBaoGoods;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief convert(DaTaoKeDetail detail) {
|
| | | TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief();
|
| | | taoBaoGoods.setAuctionId(detail.getGoodsId());
|
| | | taoBaoGoods.setBiz30day(detail.getSalesNum());
|
| | | taoBaoGoods.setCouponAmount(detail.getQuanPrice());
|
| | | taoBaoGoods.setCouponInfo(String.format("满%s元减%s元", detail.getQuanCondition(),
|
| | | MoneyBigDecimalUtil.getWithNoZera(detail.getQuanPrice())));
|
| | | taoBaoGoods.setCouponLeftCount(detail.getQuanSurplus());
|
| | | taoBaoGoods.setCouponStartFee(new BigDecimal(detail.getQuanCondition()));
|
| | | if (detail.getQuanReceive() != null)
|
| | | taoBaoGoods.setCouponTotalCount(detail.getQuanSurplus() + detail.getQuanReceive());
|
| | | taoBaoGoods.setPictUrl(detail.getPic());
|
| | | taoBaoGoods.setPictUrlWhite(detail.getPic());
|
| | | taoBaoGoods.setSellerId(detail.getSellerId());
|
| | | taoBaoGoods.setShopTitle("");
|
| | | taoBaoGoods.setTitle(detail.getdTitle());
|
| | | taoBaoGoods.setUserType(detail.getIsTmall());
|
| | | taoBaoGoods.setZkPrice(detail.getOrgPrice());
|
| | | taoBaoGoods.setTkRate(detail.getCommission());
|
| | | taoBaoGoods.setTkCommFee(new BigDecimal("0"));
|
| | | taoBaoGoods.setState(0);
|
| | | return taoBaoGoods;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief convert(DaTaoKeDetailV2 detail) {
|
| | | TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief();
|
| | | taoBaoGoods.setAuctionId(detail.getGoodsId());
|
| | | taoBaoGoods.setBiz30day(detail.getMonthSales());
|
| | | // 券相关转换
|
| | | taoBaoGoods.setCouponAmount(detail.getCouponPrice());
|
| | | taoBaoGoods.setCouponInfo(String.format("满%s元减%s元", detail.getCouponConditions(),
|
| | | taoBaoGoods.setCouponInfo(String.format("满%s元减%s元", detail.getOriginalPrice(),
|
| | | MoneyBigDecimalUtil.getWithNoZera(detail.getCouponPrice())));
|
| | | if (detail.getCouponTotalNum() != null && detail.getCouponReceiveNum() != null)
|
| | | taoBaoGoods.setCouponLeftCount(detail.getCouponTotalNum() - detail.getCouponReceiveNum());
|
| | | else
|
| | | taoBaoGoods.setCouponLeftCount(0);
|
| | | taoBaoGoods.setCouponStartFee(detail.getOriginalPrice());
|
| | | try {
|
| | | taoBaoGoods.setCouponStartFee(detail.getOriginalPrice());
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | taoBaoGoods.setCouponTotalCount(detail.getCouponTotalNum());
|
| | | taoBaoGoods.setCouponLink(detail.getCouponLink());
|
| | | taoBaoGoods.setCouponEffectiveStartTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(detail.getCouponStartTime(), "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd"));
|
| | | taoBaoGoods.setCouponEffectiveEndTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(detail.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd"));
|
| | |
|
| | | taoBaoGoods.setPictUrl(detail.getMainPic());
|
| | | taoBaoGoods.setPictUrlWhite(detail.getMainPic());
|
| | | if (taoBaoGoods.getPictUrl() != null && !taoBaoGoods.getPictUrl().startsWith("http"))
|
| | |
| | |
|
| | | String url = "";
|
| | | try {
|
| | | url = String.format("https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%s",
|
| | | url = String.format(
|
| | | "http://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%s&qq-pf-to=pcqq.group",
|
| | | URLEncoder.encode(data.toString(), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | HttpClient client = new HttpClient();
|
| | | GetMethod gm = new GetMethod(url);
|
| | | String result = null;
|
| | | try {
|
| | | gm.setRequestHeader("user-agent",
|
| | | "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Mobile Safari/537.36");
|
| | | gm.setRequestHeader("cache-control", "max-age=0");
|
| | | gm.setRequestHeader("sec-fetch-mode", "navigate");
|
| | | gm.setRequestHeader("sec-fetch-site", "none");
|
| | | gm.setRequestHeader("sec-fetch-user", "?1");
|
| | | gm.setRequestHeader("upgrade-insecure-requests", "1");
|
| | | gm.setRequestHeader("cookie",
|
| | | "t=2ef08e4a12314c12dcd98d2ec480dd69; thw=cn; hng=CN%7Czh-CN%7CCNY%7C156; x=e%3D1%26p%3D*%26s%3D0%26c%3D0%26f%3D0%26g%3D0%26t%3D0%26__ll%3D-1%26_ato%3D0; ali_ab=113.251.19.3.1554796147005.0; UM_distinctid=16b9d8257dd388-0a96f36f947888-e343166-1fa400-16b9d8257df114; WAPFDFDTGFG=%2B4cMKKP%2B8PI%2BuhLvELc2mB6zAz5Z54E%3D; _w_app_lg=0; enc=00wU0%2BKYu9Yf1tHSawG%2Bc4aMZojqg8eB6baoMr9Z8Ir4qJ6hRhMhdWQxbM71vvxv6OCsxN50T0xA1gJGIdFm7w%3D%3D; cna=Q9eYFEM1rm8CAXH7EKUDSamu; miid=769739881160810491; lgc=%5Cu6930%5Cu89C6%5Cu79D1%5Cu6280; tracknick=%5Cu6930%5Cu89C6%5Cu79D1%5Cu6280; tg=0; mt=ci=7_1; cookie2=13ad477d84d5e6659aa7855de3617163; _tb_token_=ee895586817b0; dnk=%5Cu6930%5Cu89C6%5Cu79D1%5Cu6280; v=0; _m_h5_tk=286f649add5207dfe82e770832daf1cc_1573547306314; _m_h5_tk_enc=137c39dafc279e40edc796770d3eda8f; tk_trace=oTRxOWSBNwn9dPyorMJE%2FoPdY8zZPEr%2FCrvCMS%2BG3sTRRWrQ%2BVVTl09ME1KrXdbd3QNiuPM1YZeXJrHpvLuG%2FSvA2umbWq5jqrcw%2FDpk1Lj6yQFVptx6jw71DzuBbw%2BuZLEozdKGb%2BZr85uzSnUSWfVAqZprzoB%2Bfde2IHnHJp651xghkKpmsSBgY5muhOI7FvNfc8zH1BIvygVQSEIa1bCCgy2VJl%2FkyuTXaGHb%2FAKxL566%2FLult1lRlo8RZx9s76BhXe7PTot5MPGrayPkRiqWfVdg3C7gFWRjrjjKriN47mbQazOoIM7knBX%2B3mnnmwWbCQjKiuA6I8W9ng%3D%3D; _cc_=VFC%2FuZ9ajQ%3D%3D; unb=3327215652; uc1=lng=zh_CN&tag=8&cookie16=W5iHLLyFPlMGbLDwA%2BdvAGZqLg%3D%3D&cookie15=VT5L2FSpMGV7TQ%3D%3D&cookie14=UoTbnrCeRJd%2F2g%3D%3D&pas=0&existShop=false&cookie21=VFC%2FuZ9aj38X; uc3=vt3=F8dByuWjrX8oBIwXl2Q%3D&nk2=sbdfkkkB37A%3D&id2=UNN%2F6whEupDGWQ%3D%3D&lg2=WqG3DMC9VAQiUQ%3D%3D; csg=30373d82; cookie17=UNN%2F6whEupDGWQ%3D%3D; skt=6a0617b2d0843ef4; existShop=MTU3MzgxNDAxNw%3D%3D; uc4=id4=0%40UgQ3BPth2rlXv3PxjwesD5MgnRD3&nk4=0%40s9JQzQv3gdCkG6YVO6ulkEbNug%3D%3D; _l_g_=Ug%3D%3D; sg=%E6%8A%8021; _nk_=%5Cu6930%5Cu89C6%5Cu79D1%5Cu6280; cookie1=AnRaCZfOZrWoY8u%2BoXxB8y%2FnnwnZszWqI6Bbr5BrFtM%3D; isg=BOnpxPqJkNY3p6zvIy1AdcEC-JVDtt3of1m6aoveZVAPUglk0wbtuNdAFL5BUXUg; l=dBgUvWMcqlf1dR9EBOCanurza77OSIRYYuPzaNbMi_5IT6T6q1QOkBPUkF96VfWfTVLB47_ypV99-etkZ2ejm8IpXUJsAMc.");
|
| | | client.executeMethod(gm);
|
| | | result = gm.getResponseBodyAsString();
|
| | | } catch (HttpException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | Connection.Response doc = Jsoup.connect(url).ignoreContentType(true).timeout(1000 * 10)
|
| | | .userAgent(
|
| | | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362")
|
| | | .header("Accept", "text/html, application/xhtml+xml, application/xml; q=0.9, */*; q=0.8")
|
| | | .header("Accept-Language", "zh-CN").header("Host", "acs.m.taobao.com")
|
| | | .header("Upgrade-Insecure-Requests", "1")
|
| | | .header("Cookie",
|
| | | "_cc_=VFC%2FuZ9ajQ%3D%3D; isg=BLu7TvdFYk89dV4DMXO7XNRGU58lEM8SDjV-ja14l7rRDNvuNeBfYtlOJmznNycK; thw=cn; miid=1490566681358073134; x=e%3D1%26p%3D*%26s%3D0%26c%3D0%26f%3D0%26g%3D0%26t%3D0%26__ll%3D-1%26_ato%3D0; cna=ZW8rFCpNP1gCAWpXAiKqMzqi; tracknick=tb23001560; l=cBxbffilq1UJdAFCBOCanurza77OSdAYYuPzaNbMi_5NE6T1BR7Ok6G1vF96VsWdOW8B4NSiTkp9-etkZ3Znq9SpXUJ1.; tg=0; _w_app_lg=19; WAPFDFDTGFG=%2B4cMKKP%2B8PI%2BtNYpkiAuTPLkiJB1kcwi")
|
| | | .execute();
|
| | | result = doc.body();
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
|
| | | JSONObject resultOBJ = JSONObject.fromObject(result);
|
| | |
| | | if (elements.size() >= 0) {
|
| | | for (int i = 0; i < elements.size(); i++) {
|
| | | String content = elements.get(i).toString();
|
| | | if (content.contains("var _DATA_Mdskip")) {
|
| | | if (content.contains("var _DATA_Detail")) {
|
| | | content = content.replace("<script>", "");
|
| | | content = content.replace("</script>", "");
|
| | |
|
| | | if (content.contains("videoDetail")) {
|
| | | content += ";function getData(){ var json={title:_DATA_Mdskip.item.title,pictUrl:_DATA_Mdskip.item.videoDetail.videoThumbnailURL}; return JSON.stringify(json);}";
|
| | | content += ";function getData(){ var json={title:_DATA_Detail.item.title,pictUrl:_DATA_Detail.item.images[0]}; return JSON.stringify(json);}";
|
| | | } else {
|
| | | content += ";function getData(){ var json={title:_DATA_Mdskip.item.title,pictUrl:_DATA_Mdskip.item.videos[0].videoThumbnailURL}; return JSON.stringify(json);}";
|
| | | content += ";function getData(){ var json={title:_DATA_Detail.item.title,pictUrl:_DATA_Detail.item.images[0]}; return JSON.stringify(json);}";
|
| | | }
|
| | |
|
| | | ScriptEngineManager manager = new ScriptEngineManager();
|
| | |
| | | taoBaoGoodsBrief = new TaoBaoGoodsBrief();
|
| | | taoBaoGoodsBrief.setTitle(title.toString());
|
| | | taoBaoGoodsBrief.setPictUrl(pictUrl.toString());
|
| | | if (!pictUrl.toString().startsWith("http")) {
|
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize220Img("http:" + pictUrl.toString()));
|
| | | }
|
| | | }
|
| | |
|
| | | break;
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | private final static String[] taoTokenSymbols = new String[] { "₳-₳", "¥-¥", "¥-¥", "€-€", "\\$-\\$", "₴-₴", "¢-¢",
|
| | | "₤-₤" };
|
| | |
|
| | | /**
|
| | | * 从文本中提取淘口令 @Title: getTokenListFromText @Description: @param str @return
|
| | | * List<String> 返回类型 @throws
|
| | | */
|
| | | public static List<String> getTokenListFromText(String str) {
|
| | | String[] marks = taoTokenSymbols;
|
| | |
|
| | | return getTokenListFromText(str, Arrays.asList(marks));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 从文本中提取淘口令(括号的口令也算)
|
| | | * |
| | | * @param str
|
| | | * @return
|
| | | */
|
| | | public static List<String> getTokenListFromTextWithKuoHao(String str) {
|
| | | String[] marks = taoTokenSymbols;
|
| | | List<String> list = new ArrayList<>();
|
| | | for (String st : marks)
|
| | | list.add(st);
|
| | | list.add("\\(-\\)");
|
| | | list.add("(-)");
|
| | | return getTokenListFromText(str, list);
|
| | | }
|
| | |
|
| | | public static List<String> getTokenListFromText(String str, List<String> markList) {
|
| | | List<String> expressList = new ArrayList<>();
|
| | | for (String st : markList) {
|
| | | expressList.add(String.format("(%s{1}[A-Za-z0-9]{11,13}+%s{1})", st.split("-")[0], st.split("-")[1]));
|
| | | }
|
| | | String pattern = StringUtil.concat(expressList, "|");
|
| | | Pattern r = Pattern.compile(pattern);
|
| | | Matcher m = r.matcher(str);
|
| | | List<String> urlList = new ArrayList<>();
|
| | | while (m.find()) {
|
| | | urlList.add(m.group());
|
| | | }
|
| | | return urlList;
|
| | | }
|
| | |
|
| | | }
|