| | |
| | | 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 org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
| | | import org.apache.commons.httpclient.methods.GetMethod;
|
| | | import org.apache.commons.httpclient.params.HttpMethodParams;
|
| | | import org.hibernate.cache.spi.NaturalIdCacheKey;
|
| | | import org.jsoup.Connection;
|
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | |
| | | 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) {
|
| | |
| | | * @throws
|
| | | */
|
| | | public static List<String> getTokenListFromText(String str) {
|
| | | String pattern = "(₳{1}[A-Za-z0-9]+₳{1})|(¥{1}[A-Za-z0-9]+¥{1})|(¥{1}[A-Za-z0-9]+¥{1})|(€{1}[A-Za-z0-9]+€{1})";
|
| | | String[] marks = new String[] { "₳", "¥", "¥", "€", "\\$", "₴", "¢", "₤" };
|
| | |
|
| | | return getTokenListFromText(str, Arrays.asList(marks));
|
| | | }
|
| | |
|
| | | 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, st));
|
| | | }
|
| | | String pattern = StringUtil.concat(expressList, "|");
|
| | | Pattern r = Pattern.compile(pattern);
|
| | | Matcher m = r.matcher(str);
|
| | | List<String> urlList = new ArrayList<>();
|