Commit b953b6de by 马黎滨

凤凰热搜采集url

parent a4df8c55
......@@ -78,14 +78,18 @@ public class FengHuangSearchCrawler {
}
if (StringUtils.isNotBlank(htmlBody) && htmlBody.contains("data")) {
JSONArray jsonArray = JSONObject.parseObject(htmlBody).getJSONArray("data").getJSONObject(0).getJSONArray("item");
// log.info(jsonArray);
if (jsonArray != null) {
for (int i = 0; i < jsonArray.size(); i++) {
Integer rank = i + 1;
String name = jsonArray.getJSONObject(i).getString("title");
String fenghuangUrl = "https://so.ifeng.com/?q="+name;
HotSearchList hotSearchList = new HotSearchList(fenghuangUrl, name, null,
rank, HotSearchType.凤凰新闻热搜.name());
String fenghuangUrl = null;
String id = jsonArray.getJSONObject(i).getString("id");
if(id.contains("hw_")){
id = id.substring(id.indexOf("hw_")+3);
fenghuangUrl = "https://so.ifeng.com/?q="+id;
}
HotSearchList hotSearchList = new HotSearchList(fenghuangUrl, name, null, rank,
HotSearchType.凤凰新闻热搜.name());
list.add(hotSearchList);
}
}
......
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