From 9d8dfb01ff72c57abad3b80f3d65e81a5354db03 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期五, 12 七月 2019 09:10:38 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java index 27d076a..5b19dd5 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java @@ -13,6 +13,7 @@ import org.yeshi.utils.HttpUtil; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.dto.pdd.PDDGoodsResult; @@ -86,12 +87,22 @@ map.put("keyword", sf.getKw()); map.put("pid", PID_FANLI); String result = baseRequest(map); + + try { + result = new String(result.getBytes("GBK"),"UTF-8"); +// result = new String(result.getBytes("GBK"),"ISO-8859-1"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + JSONObject json = JSONObject.fromObject(result); JSONObject root = json.optJSONObject("goods_search_response"); JSONArray array = root.optJSONArray("goods_list"); Type type = new TypeToken<List<PDDGoodsDetail>>() { }.getType(); - List<PDDGoodsDetail> goodsList = new Gson().fromJson(array.toString(), type); + + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type); int totalCount = json.optInt("total_count"); return new PDDGoodsResult(totalCount, goodsList); } @@ -138,6 +149,17 @@ System.out.println(result); } + /** + * 鑾峰彇璁㈠崟 + * + * @param page + * -椤电爜 + * @param pageSize-姣忛〉鏁伴噺 + * @param startTime-寮�濮嬫椂闂� + * @param endTime-缁撴潫鏃堕棿 + * 涓庡紑濮嬫椂闂翠笉寰楀ぇ浜�24灏忔椂 + * @return + */ public static PDDOrderResult getOrders(int page, int pageSize, long startTime, long endTime) { Map<String, String> map = new HashMap<>(); map.put("type", "pdd.ddk.order.list.increment.get"); -- Gitblit v1.8.0