@Override public int getTotalPage(Map<String, String> param) { String countContent = TLCSpiderRequest.postViaProxy(URL_PRODUCT_LIST, param, TLCSpiderRequest.ProxyType.HTTPS); String countStr = TLCSpiderJsonUtil.getString(countContent, "Data"); String totalCount = TLCSpiderJsonUtil.getString(countStr, "TotalCount"); int pageSize = Integer.parseInt(PAGE_SIZE); int totalPage = Integer.parseInt(totalCount) % pageSize == 0 ? Integer.parseInt(totalCount) / pageSize : (Integer.parseInt(totalCount) / pageSize + 1); return totalPage; }
@Test public void testHttpsProxy() { String url = TLCSpiderPropertiesUtil.getResource("tlc.spider.p2p.rdnsyherjz.url.list"); Map<String, String> param = new HashMap(); param.put("PageIndex", TLCSpiderConstants.SPIDER_PARAM_PAGE_ONE); param.put("PageSize", "10"); param.put("targetAction", "CmbFinancingSearch"); param.put("Interest", ""); param.put("Duration", ""); param.put("ProjectStatus", ""); param.put("ProjectAmount", ""); String countContent = TLCSpiderRequest.postViaProxy(url, param, TLCSpiderRequest.ProxyType.HTTPS); // String countContent = TLCSpiderRequest.post(url, param); String countStr = TLCSpiderJsonUtil.getString(countContent, "Data"); String totalCount = TLCSpiderJsonUtil.getString(countStr, "TotalCount"); System.out.println(totalCount); }
@Override public List<TransObject> getSpiderDataList(Map<String, String> param) { String productContent = TLCSpiderRequest.postViaProxy(URL_PRODUCT_LIST, param, TLCSpiderRequest.ProxyType.HTTPS); String productJsonStr = TLCSpiderJsonUtil.getString(productContent, "Data"); List<RDNSYHERJZ> productList = TLCSpiderJsonUtil.json2Array(productJsonStr, "ResultList", RDNSYHERJZ.class, "YMInterest"); List<TransObject> transObjectList = new ArrayList(); for (RDNSYHERJZ product : productList) { TransObject transObject = convertToTransObject(product); transObjectList.add(transObject); } return transObjectList; }