Commit 5b2136e2 by zhiwei

微博热搜添加区分推荐位icon字段

parent ae0a5009
...@@ -39,7 +39,6 @@ public class WeiboHotSearchCrawler { ...@@ -39,7 +39,6 @@ public class WeiboHotSearchCrawler {
* @Title: weiboHotSearchTest * @Title: weiboHotSearchTest
* @author hero * @author hero
* @Description: TODO(PC端微博热搜采集) * @Description: TODO(PC端微博热搜采集)
* @param 设定文件
* @return void 返回类型 * @return void 返回类型
*/ */
public static List<HotSearchList> weiboHotSearch(){ public static List<HotSearchList> weiboHotSearch(){
...@@ -67,7 +66,7 @@ public class WeiboHotSearchCrawler { ...@@ -67,7 +66,7 @@ public class WeiboHotSearchCrawler {
int hotCount = Integer.valueOf(num); int hotCount = Integer.valueOf(num);
int rankCount = Integer.valueOf(rank); int rankCount = Integer.valueOf(rank);
HotSearchList hotSearch = new HotSearchList(id, name, hotCount,true, rankCount, HotSearchType.微博热搜.name()); HotSearchList hotSearch = new HotSearchList(id, name, hotCount,true, rankCount, HotSearchType.微博热搜.name(),null);
list.add(hotSearch); list.add(hotSearch);
} catch (Exception e) { } catch (Exception e) {
SendMailWeibo.sendMail("微博热搜采集出现问题", "859548429@qq.com"); SendMailWeibo.sendMail("微博热搜采集出现问题", "859548429@qq.com");
...@@ -104,7 +103,6 @@ public class WeiboHotSearchCrawler { ...@@ -104,7 +103,6 @@ public class WeiboHotSearchCrawler {
* @Title: weiboHotSearchByPhoneTest * @Title: weiboHotSearchByPhoneTest
* @author hero * @author hero
* @Description: TODO(手机端Iphone 微博热搜采集) * @Description: TODO(手机端Iphone 微博热搜采集)
* @param 设定文件
* @return void 返回类型 * @return void 返回类型
*/ */
public static List<HotSearchList> weiboHotSearchByPhone(){ public static List<HotSearchList> weiboHotSearchByPhone(){
...@@ -120,7 +118,7 @@ public class WeiboHotSearchCrawler { ...@@ -120,7 +118,7 @@ public class WeiboHotSearchCrawler {
try { try {
JSONObject json = JSONObject.parseObject(htmlBody).getJSONObject("data"); JSONObject json = JSONObject.parseObject(htmlBody).getJSONObject("data");
JSONArray cards = json.getJSONArray("cards"); JSONArray cards = json.getJSONArray("cards");
int rank = 1; int rank = 0;
for(int i=0;i<cards.size();i++){ for(int i=0;i<cards.size();i++){
try { try {
JSONObject card = cards.getJSONObject(i); JSONObject card = cards.getJSONObject(i);
...@@ -135,8 +133,12 @@ public class WeiboHotSearchCrawler { ...@@ -135,8 +133,12 @@ public class WeiboHotSearchCrawler {
JSONObject cardInfo = cardGroup.getJSONObject(j); JSONObject cardInfo = cardGroup.getJSONObject(j);
String name = cardInfo.getString("desc"); String name = cardInfo.getString("desc");
int hotCount = cardInfo.getIntValue("desc_extr"); int hotCount = cardInfo.getIntValue("desc_extr");
String icon = cardInfo.getString("icon");
if(StringUtils.isNotBlank(icon)){
icon = icon.split("_")[1].split(".png")[0];
}
String id = "http://s.weibo.com/weibo/"+URLCodeUtil.getURLEncode(name, "utf-8") + "&Refer=top"; String id = "http://s.weibo.com/weibo/"+URLCodeUtil.getURLEncode(name, "utf-8") + "&Refer=top";
HotSearchList hotSearch = new HotSearchList(id, name, hotCount, hot, rank, HotSearchType.微博热搜.name()); HotSearchList hotSearch = new HotSearchList(id, name, hotCount, hot, rank, HotSearchType.微博热搜.name(), icon);
logger.info("采集到的数据:::{}", hotSearch); logger.info("采集到的数据:::{}", hotSearch);
result.add(hotSearch); result.add(hotSearch);
rank++; rank++;
......
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