| | |
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoLinkService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoHttpUtil;
|
| | |
| | | }
|
| | | return parsePhoneTmAndTb(id);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "无法解析到淘宝商品ID", burl);
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | LogHelper.error("无法解析到淘宝商品ID:" + burl);
|
| | | return null;
|
| | | }
|
| | |
|
| | |
| | | * @return
|
| | | */
|
| | |
|
| | | public static List<ImageInfo> getTBDetailImageWithSizev2(Long auctionId) {
|
| | | public static List<ImageInfo> getTBDetailImageWithSizev2(Long auctionId, ProxyIP ip) {
|
| | | List<ImageInfo> imgList = new ArrayList<>();
|
| | | try {
|
| | | Map<String, String> headers = new HashMap<>();
|
| | | headers.put("User-Agent",
|
| | | "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");
|
| | | headers.put("Referer", "https://detail.tmall.com/item.htm?id=" + auctionId);
|
| | | String url = String.format("https://hws.m.taobao.com/cache/desc/5.0?id=" + auctionId);
|
| | | String result = HttpUtil.get(url);
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | | String result = HttpUtil.get(url, headers, ip);
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | |
|
| | | JSONArray array = data.optJSONObject("wdescContent").optJSONArray("pages");
|
| | | if (array != null) {
|
| | | String html = "";
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | String itemStr = array.optString(i).replace("<img", "<a").replace("</img>", "<a>");
|
| | | html += itemStr;
|
| | | }
|
| | | Document doc = Jsoup.parse(html);
|
| | | Elements items = doc.getElementsByTag("a");
|
| | | for (int i = 0; i < items.size(); i++) {
|
| | | ImageInfo img = new ImageInfo();
|
| | | Element item = items.get(i);
|
| | | if (StringUtil.isNullOrEmpty(item.ownText()))
|
| | | continue;
|
| | | if (!StringUtil.isNullOrEmpty(item.attr("size"))) {
|
| | | img.setWidth(Integer.parseInt(item.attr("size").split("x")[0]));
|
| | | img.setHeight(Integer.parseInt(item.attr("size").split("x")[1]));
|
| | | JSONArray array = data.optJSONObject("wdescContent").optJSONArray("pages");
|
| | | if (array != null) {
|
| | | String html = "";
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | String itemStr = array.optString(i).replace("<img", "<a").replace("</img>", "<a>");
|
| | | html += itemStr;
|
| | | }
|
| | | if (item.ownText().startsWith("http"))
|
| | | img.setPicture(item.ownText().trim());
|
| | | else
|
| | | img.setPicture("http:" + item.ownText().trim());
|
| | | if (img != null && img.getPicture() != null && img.getPicture().endsWith(".jpg"))
|
| | | imgList.add(img);
|
| | | Document doc = Jsoup.parse(html);
|
| | | Elements items = doc.getElementsByTag("a");
|
| | | for (int i = 0; i < items.size(); i++) {
|
| | | ImageInfo img = new ImageInfo();
|
| | | Element item = items.get(i);
|
| | | if (StringUtil.isNullOrEmpty(item.ownText()))
|
| | | continue;
|
| | | if (!StringUtil.isNullOrEmpty(item.attr("size"))) {
|
| | | img.setWidth(Integer.parseInt(item.attr("size").split("x")[0]));
|
| | | img.setHeight(Integer.parseInt(item.attr("size").split("x")[1]));
|
| | | }
|
| | | if (item.ownText().startsWith("http"))
|
| | | img.setPicture(item.ownText().trim());
|
| | | else
|
| | | img.setPicture("http:" + item.ownText().trim());
|
| | | if (img != null && img.getPicture() != null && img.getPicture().endsWith(".jpg"))
|
| | | imgList.add(img);
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | taoBaoGoods.setCouponStartFee(commonGoods.getCouponStartPrice());
|
| | | taoBaoGoods.setCouponTotalCount(commonGoods.getCouponTotalCount());
|
| | | taoBaoGoods.setPictUrl(commonGoods.getPicture());
|
| | | taoBaoGoods.setPictUrlWhite(commonGoods.getPictureWhite());
|
| | | taoBaoGoods.setSellerId(commonGoods.getSellerId());
|
| | | taoBaoGoods.setShopTitle(commonGoods.getSellerName());
|
| | | taoBaoGoods.setTitle(commonGoods.getTitle());
|
| | |
| | | return taoBaoGoods;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取淘宝联盟的授权链接
|
| | | * |
| | | * @param appKey
|
| | | * -应用Key
|
| | | * @param callBackUrl
|
| | | * -回调链接
|
| | | * @param uid-用户ID
|
| | | * @return
|
| | | */
|
| | | public static String getTaoBaoUnionAuthUrl(String appKey, String callBackUrl, Long uid, String source) {
|
| | | if (uid == null)
|
| | | return null;
|
| | | long timestamp = System.currentTimeMillis();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("u", uid);
|
| | | json.put("t", timestamp);
|
| | | json.put("s", source);
|
| | | String url = null;
|
| | | try {
|
| | | url = String.format(
|
| | | "https://oauth.taobao.com/authorize?response_type=code&client_id=%s&redirect_uri=%s&state=%s&view=wap",
|
| | | appKey, callBackUrl,
|
| | | URLEncoder.encode(AESUtil.encrypt(json.toString(), Constant.UIDAESKEY), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return url;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief getSimpleGoodsBrief(Long actionId) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("itemNumId", actionId + "");
|
| | |
|
| | | String url = "";
|
| | | try {
|
| | | url = String.format("https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%s",
|
| | | URLEncoder.encode(data.toString(), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | String result = HttpUtil.get(url);
|
| | | JSONObject resultOBJ = JSONObject.fromObject(result);
|
| | | if (resultOBJ.optJSONObject("data") != null) {
|
| | | data = resultOBJ.optJSONObject("data");
|
| | | JSONObject item = data.optJSONObject("item");
|
| | | JSONObject seller = data.optJSONObject("seller");
|
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
|
| | | goods.setAuctionId(item.optLong("itemId"));
|
| | | goods.setTitle(item.optString("title"));
|
| | | if (item.optJSONArray("images") != null && item.optJSONArray("images").size() > 0)
|
| | | {
|
| | | String picture=item.optJSONArray("images").optString(0);
|
| | | goods.setPictUrl(picture.startsWith("http")?picture:"https:"+picture);
|
| | | }
|
| | | goods.setSellerId(seller.optLong("shopId"));
|
| | | goods.setShopTitle(seller.optString("shopName"));
|
| | | return goods;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | String s = channelMap.get("3");
|
| | | System.out.println(s);
|