| | |
| | |
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | |
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_search_response");
|
| | | if (root == null) {
|
| | | return null;
|
| | | } |
| | | |
| | | JSONArray array = root.optJSONArray("goods_list");
|
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | |
|
| | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_basic_detail_response");
|
| | | if (root == null) {
|
| | | return null;
|
| | | }
|
| | | JSONArray array = root.optJSONArray("list");
|
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | |
|
| | |
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_cats_get_response");
|
| | | JSONArray array = root.optJSONArray("goods_cats_list");
|
| | | }
|
| | | |
| | | |
| | | public static void getThemes(Integer page, Integer pageSize) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.theme.list.get");
|
| | | map.put("page", page + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | String result = baseRequest(map);
|
| | | |
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("theme_list_get_response");
|
| | | JSONArray array = root.optJSONArray("theme_list");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | System.out.println(array.optJSONObject(i).optString("id"));
|
| | | System.out.println(array.optJSONObject(i).optString("name"));
|
| | | System.out.println(array.optJSONObject(i).optString("image_url"));
|
| | | System.out.println(array.optJSONObject(i).optString("goods_num"));
|
| | | System.out.println("-------------------------------------------");
|
| | | }
|
| | | |
| | | System.out.println(root.optLong("total"));
|
| | | }
|
| | |
|
| | |
|
| | |
| | | String result = baseRequest(map);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("top_goods_list_get_response");
|
| | | if (root == null) {
|
| | | return null;
|
| | | }
|
| | | JSONArray array = root.optJSONArray("list");
|
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {}.getType();
|
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | |
| | | String result = baseRequest(map);
|
| | | JSONObject root = JSONObject.fromObject(result);
|
| | | JSONObject json = root.optJSONObject("goods_promotion_url_generate_response");
|
| | | array = json.optJSONArray("goods_promotion_url_list");
|
| | | if (array != null && array.size() > 0)
|
| | | return array.optJSONObject(0).optString("short_url");
|
| | | if (json == null) {
|
| | | return null;
|
| | | }
|
| | | JSONArray resultArray = json.optJSONArray("goods_promotion_url_list");
|
| | | if (resultArray != null && resultArray.size() > 0)
|
| | | return resultArray.optJSONObject(0).optString("short_url");
|
| | | return null;
|
| | | }
|
| | |
|
| | |
| | | String result = baseRequest(map);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | JSONObject root = resultJson.optJSONObject("goods_detail_response");
|
| | | array = root.optJSONArray("goods_details");
|
| | | if (root == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | JSONArray resultArray = root.optJSONArray("goods_details");
|
| | | if (resultArray == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | List<PDDGoodsDetail> goodsList = new Gson().fromJson(array.toString(), type);
|
| | | List<PDDGoodsDetail> goodsList = new Gson().fromJson(resultArray.toString(), type);
|
| | | if (goodsList != null && goodsList.size() > 0)
|
| | | return goodsList.get(0);
|
| | | return null;
|