Commit d59803e9 by leiliangliang

增加微博信息及用户信息异常捕获

parent 402290c1
...@@ -623,6 +623,7 @@ public class WeiboHotSearchCrawler { ...@@ -623,6 +623,7 @@ public class WeiboHotSearchCrawler {
public static List<WeiBoUser> analysisWeiBoUsers(JSONArray cardGroup, String topic) { public static List<WeiBoUser> analysisWeiBoUsers(JSONArray cardGroup, String topic) {
List<WeiBoUser> weiBoUserList = new ArrayList(); List<WeiBoUser> weiBoUserList = new ArrayList();
//解析weibo人物信息 //解析weibo人物信息
try {
Date date = new Date(); Date date = new Date();
for (int i = 0; i < cardGroup.size(); i++) { for (int i = 0; i < cardGroup.size(); i++) {
Integer cardType = Integer.valueOf(cardGroup.getJSONObject(i).getString("card_type")); Integer cardType = Integer.valueOf(cardGroup.getJSONObject(i).getString("card_type"));
...@@ -686,6 +687,9 @@ public class WeiboHotSearchCrawler { ...@@ -686,6 +687,9 @@ public class WeiboHotSearchCrawler {
return weiBoUserList; return weiBoUserList;
} }
} }
} catch (Exception e) {
log.error("解析人物信息失败", e);
}
return Collections.emptyList(); return Collections.emptyList();
} }
...@@ -698,6 +702,8 @@ public class WeiboHotSearchCrawler { ...@@ -698,6 +702,8 @@ public class WeiboHotSearchCrawler {
* @return * @return
*/ */
public static WeiBoMassage analysisWeiboMBlog(JSONObject jsonObject, String topic) { public static WeiBoMassage analysisWeiboMBlog(JSONObject jsonObject, String topic) {
WeiBoMassage weiBoMassage = null;
try {
JSONObject mblog = jsonObject.getJSONObject("mblog"); JSONObject mblog = jsonObject.getJSONObject("mblog");
String type = mblog.getJSONObject("title").getString("text"); String type = mblog.getJSONObject("title").getString("text");
String card_type = jsonObject.getString("card_type"); String card_type = jsonObject.getString("card_type");
...@@ -737,7 +743,7 @@ public class WeiboHotSearchCrawler { ...@@ -737,7 +743,7 @@ public class WeiboHotSearchCrawler {
Date editTime = null; Date editTime = null;
try { try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", java.util.Locale.US); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US);
//创建时间 //创建时间
String created_at = mblog.getString("created_at"); String created_at = mblog.getString("created_at");
...@@ -771,7 +777,7 @@ public class WeiboHotSearchCrawler { ...@@ -771,7 +777,7 @@ public class WeiboHotSearchCrawler {
content = mblog.getString("text"); content = mblog.getString("text");
} }
WeiBoMassage weiBoMassage = new WeiBoMassage(userId, content, userName, mid, createTime, editTime, cardType, showType, weiBoMassage = new WeiBoMassage(userId, content, userName, mid, createTime, editTime, cardType, showType,
repostCount, commentCount, attitudeCount, source, type, topic, profileImageUrl); repostCount, commentCount, attitudeCount, source, type, topic, profileImageUrl);
//默认不转发为0 //默认不转发为0
weiBoMassage.setForward(0); weiBoMassage.setForward(0);
...@@ -829,6 +835,9 @@ public class WeiboHotSearchCrawler { ...@@ -829,6 +835,9 @@ public class WeiboHotSearchCrawler {
} }
weiBoMassage.setPlayCount(playCount); weiBoMassage.setPlayCount(playCount);
weiBoMassage.setPictureUrlList(pictureUrlList); weiBoMassage.setPictureUrlList(pictureUrlList);
} catch (Exception e) {
log.error("解析微博信息失败", e);
}
return weiBoMassage; return weiBoMassage;
} }
......
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