Commit 0ca8540e by chenweitao

Merge branch 'working' into 'master'

增加脉脉话题重试次数

See merge request !225
parents 96fb7113 2247b2af
...@@ -29,27 +29,38 @@ public class MaiMaiTopicCrawler { ...@@ -29,27 +29,38 @@ public class MaiMaiTopicCrawler {
String url = "https://open.taou.com/maimai/feed/v6/hot_list_entry/feeds?page_version=2&tab_id=topic&version=6.2.34&u=232258287&access_token=1.4c82e8ad6d6b4e03262a48f334dea336"; String url = "https://open.taou.com/maimai/feed/v6/hot_list_entry/feeds?page_version=2&tab_id=topic&version=6.2.34&u=232258287&access_token=1.4c82e8ad6d6b4e03262a48f334dea336";
String htmlBody = null; String htmlBody = null;
Request request = RequestUtils.wrapGet(url); Request request = RequestUtils.wrapGet(url);
for (int x = 0; x <= 2; x++) {
Response response = HttpClientUtils.httpBoot.syncCall(request, ProxyServerSupplier.NAT_HEAVY_PROXY); Response response = HttpClientUtils.httpBoot.syncCall(request, ProxyServerSupplier.NAT_HEAVY_PROXY);
if (response.hasCause()){ if (response.hasCause()){
Throwable cause = response.cause(); Throwable cause = response.cause();
log.error("脉脉话题页面连接异常...", cause); log.error("脉脉话题页面连接异常...", cause);
continue;
}else { }else {
htmlBody = response.bodyString(); htmlBody = response.bodyString();
} }
if (StringUtils.isNotBlank(htmlBody) && htmlBody.contains("topics")) { try {
JSONArray jsonArray = JSONObject.parseObject(htmlBody).getJSONArray("topics"); if (StringUtils.isNotBlank(htmlBody) && htmlBody.contains("topics")) {
if (jsonArray != null) { JSONArray jsonArray = JSONObject.parseObject(htmlBody).getJSONArray("topics");
for (int i = 0; i < jsonArray.size(); i++) { if (jsonArray != null) {
Integer rank = i + 1 ; for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i); Integer rank = i + 1 ;
String id = jsonObject.getString("id"); JSONObject jsonObject = jsonArray.getJSONObject(i);
String name = jsonObject.getString("name"); String id = jsonObject.getString("id");
String maiMaiTopicUrl = "https://maimai.cn/web/gossip/topic/global_topic_list?topic_id="+id; String name = jsonObject.getString("name");
Long count = null; String maiMaiTopicUrl = "https://maimai.cn/web/gossip/topic/global_topic_list?topic_id="+id;
HotSearchList hotSearchList = new HotSearchList(maiMaiTopicUrl, name, count, rank, HotSearchType.脉脉话题.name(),date); Long count = null;
list.add(hotSearchList); HotSearchList hotSearchList = new HotSearchList(maiMaiTopicUrl, name, count, rank, HotSearchType.脉脉话题.name(),date);
list.add(hotSearchList);
}
}
}else {
continue;
} }
} catch (Exception e) {
log.info("脉脉话题解析异常",e);
continue;
} }
break;
} }
log.info("{}, 此轮脉脉话题采集到的数据量为:{}", new Date(), list != null ? list.size() : 0); log.info("{}, 此轮脉脉话题采集到的数据量为:{}", new Date(), list != null ? list.size() : 0);
log.info("脉脉话题采集结束"); log.info("脉脉话题采集结束");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment