Commit 36e2a228 by chenweitao

Merge branch 'working' into 'master'

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

See merge request !166
parents feb24133 d59803e9
......@@ -623,6 +623,7 @@ public class WeiboHotSearchCrawler {
public static List<WeiBoUser> analysisWeiBoUsers(JSONArray cardGroup, String topic) {
List<WeiBoUser> weiBoUserList = new ArrayList();
//解析weibo人物信息
try {
Date date = new Date();
for (int i = 0; i < cardGroup.size(); i++) {
Integer cardType = Integer.valueOf(cardGroup.getJSONObject(i).getString("card_type"));
......@@ -686,6 +687,9 @@ public class WeiboHotSearchCrawler {
return weiBoUserList;
}
}
} catch (Exception e) {
log.error("解析人物信息失败", e);
}
return Collections.emptyList();
}
......@@ -698,6 +702,8 @@ public class WeiboHotSearchCrawler {
* @return
*/
public static WeiBoMassage analysisWeiboMBlog(JSONObject jsonObject, String topic) {
WeiBoMassage weiBoMassage = null;
try {
JSONObject mblog = jsonObject.getJSONObject("mblog");
String type = mblog.getJSONObject("title").getString("text");
String card_type = jsonObject.getString("card_type");
......@@ -737,7 +743,7 @@ public class WeiboHotSearchCrawler {
Date editTime = null;
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");
......@@ -771,7 +777,7 @@ public class WeiboHotSearchCrawler {
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);
//默认不转发为0
weiBoMassage.setForward(0);
......@@ -829,6 +835,9 @@ public class WeiboHotSearchCrawler {
}
weiBoMassage.setPlayCount(playCount);
weiBoMassage.setPictureUrlList(pictureUrlList);
} catch (Exception e) {
log.error("解析微博信息失败", e);
}
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