| | |
| | | return null; |
| | | } |
| | | |
| | | HttpClient client = new HttpClient(); |
| | | client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); |
| | | PostMethod pm = new PostMethod(url); |
| | | try { |
| | | client.executeMethod(pm); |
| | | Header header = pm.getResponseHeader("location"); |
| | | if (header == null) { |
| | | return null; |
| | | } |
| | | if (header.getValue() == null) { |
| | | return null; |
| | | } |
| | | if (!header.getValue().contains("detail/index.html")) { |
| | | return null; |
| | | } |
| | | String value = URLDecoder.decode(header.getValue(), "UTF-8"); |
| | | |
| | | String[] results = value.split("&"); |
| | | for (String r : results) { |
| | | if (!r.contains("product_id=")) { |
| | | continue; |
| | | } |
| | | return r.split("=")[1].trim(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return null; |
| | | String id = CSJCPSApiUtil.parseProductId(url); |
| | | return id; |
| | | // |
| | | // HttpClient client = new HttpClient(); |
| | | // client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); |
| | | // PostMethod pm = new PostMethod(url); |
| | | // try { |
| | | // client.executeMethod(pm); |
| | | // Header header = pm.getResponseHeader("location"); |
| | | // if (header == null) { |
| | | // return null; |
| | | // } |
| | | // if (header.getValue() == null) { |
| | | // return null; |
| | | // } |
| | | // if (!header.getValue().contains("detail/index.html")) { |
| | | // return null; |
| | | // } |
| | | // String value = URLDecoder.decode(header.getValue(), "UTF-8"); |
| | | // value = value.split("\\?")[1]; |
| | | // String[] results = value.split("&"); |
| | | // for (String r : results) { |
| | | // String key = r.split("=")[0].trim(); |
| | | // String val = r.split("=")[1]; |
| | | // if (!key.equalsIgnoreCase("product_id") && !key.equalsIgnoreCase("id")) { |
| | | // continue; |
| | | // } |
| | | // return val.trim(); |
| | | // } |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // return null; |
| | | } |
| | | |
| | | public static BigDecimal getPrice(int money) { |