| | |
| | | package com.yeshi.fanli.util.pinduoduo;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.select.Elements;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | public static List<String> getDetailImages(Long id) {
|
| | | List<String> imgList = new ArrayList<>();
|
| | | try {
|
| | | Document doc = Jsoup.connect("http://yangkeduo.com/goods.html?goods_id="+id)
|
| | | Document doc = Jsoup.connect("http://yangkeduo.com/goods.html?goods_id=" + id)
|
| | | .userAgent(
|
| | | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36")
|
| | | .get();
|
| | |
| | |
|
| | | }
|
| | |
|
| | | public static List<String> suggestSearch(String key) {
|
| | | List<String> list = new ArrayList<>();
|
| | | if (StringUtil.isNullOrEmpty(key))
|
| | | return list;
|
| | | String url = null;
|
| | | try {
|
| | | url = String.format("http://apiv3.yangkeduo.com/search_suggest?query=%s&pdduid=0",
|
| | | URLEncoder.encode(key, "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (url == null)
|
| | | return list;
|
| | | try {
|
| | | String result = HttpUtil.get(url);
|
| | | JSONObject dataJSON = JSONObject.fromObject(result);
|
| | | JSONArray array = dataJSON.optJSONArray("suggest_list");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | String sk = array.optJSONObject(i).optJSONObject("item_data").optString("suggestion");
|
| | | if (!StringUtil.isNullOrEmpty(sk))
|
| | | list.add(sk);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | }
|