Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
searchhotcrawler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhiwei
searchhotcrawler
Commits
ab081ccd
Commit
ab081ccd
authored
Sep 02, 2021
by
leiliangliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
list表新增微博iconUrl字段 修复weibo_user粉丝量采集异常情况
parent
e3f47934
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
src/main/java/com/zhiwei/searchhotcrawler/bean/HotSearchList.java
+5
-0
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
+12
-5
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
+3
-0
No files found.
src/main/java/com/zhiwei/searchhotcrawler/bean/HotSearchList.java
View file @
ab081ccd
...
@@ -75,6 +75,11 @@ public class HotSearchList implements Serializable{
...
@@ -75,6 +75,11 @@ public class HotSearchList implements Serializable{
private
String
icon
;
private
String
icon
;
/**
/**
* icon地址
*/
private
String
iconUrl
;
/**
* 话题讨论量或阅读量
* 话题讨论量或阅读量
*/
*/
private
Long
commentCount
;
private
Long
commentCount
;
...
...
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
View file @
ab081ccd
...
@@ -166,13 +166,15 @@ public class WeiboHotSearchCrawler {
...
@@ -166,13 +166,15 @@ public class WeiboHotSearchCrawler {
JSONObject
cardInfo
=
cardGroup
.
getJSONObject
(
j
);
JSONObject
cardInfo
=
cardGroup
.
getJSONObject
(
j
);
String
name
=
cardInfo
.
getString
(
"desc"
);
String
name
=
cardInfo
.
getString
(
"desc"
);
long
hotCount
=
cardInfo
.
getLongValue
(
"desc_extr"
);
long
hotCount
=
cardInfo
.
getLongValue
(
"desc_extr"
);
String
icon
=
cardInfo
.
getString
(
"icon"
);
String
iconUrl
=
cardInfo
.
getString
(
"icon"
);
if
(
StringUtils
.
isNotBlank
(
icon
))
{
String
icon
=
null
;
icon
=
icon
.
split
(
"_"
)[
1
].
split
(
".png"
)[
0
];
if
(
StringUtils
.
isNotBlank
(
iconUrl
))
{
icon
=
iconUrl
.
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";
String
id
=
cardInfo
.
getString
(
"scheme"
);
String
id
=
cardInfo
.
getString
(
"scheme"
);
HotSearchList
hotSearch
=
new
HotSearchList
(
id
,
name
,
hotCount
,
hot
,
rank
,
HotSearchType
.
微博热搜
.
name
(),
icon
,
date
);
HotSearchList
hotSearch
=
new
HotSearchList
(
id
,
name
,
hotCount
,
hot
,
rank
,
HotSearchType
.
微博热搜
.
name
(),
icon
,
date
);
if
(
Objects
.
nonNull
(
iconUrl
)){
hotSearch
.
setIconUrl
(
iconUrl
);}
result
.
add
(
hotSearch
);
result
.
add
(
hotSearch
);
rank
++;
rank
++;
redisDao
.
addDataToSet
(
RedisConfig
.
WEIBO_HOTSEARCHIDS
,
name
+
"_微博热搜"
);
redisDao
.
addDataToSet
(
RedisConfig
.
WEIBO_HOTSEARCHIDS
,
name
+
"_微博热搜"
);
...
@@ -513,8 +515,13 @@ public class WeiboHotSearchCrawler {
...
@@ -513,8 +515,13 @@ public class WeiboHotSearchCrawler {
Long
followerCount
=
null
;
Long
followerCount
=
null
;
if
(
followers_count
.
contains
(
"万"
))
{
if
(
followers_count
.
contains
(
"万"
))
{
String
[]
split
=
followers_count
.
split
(
"万"
);
String
[]
split
=
followers_count
.
split
(
"万"
);
followerCount
=
Long
.
valueOf
(
split
[
0
])
*
10000
;
Double
aDouble
=
Double
.
valueOf
(
split
[
0
])*
10000
;
}
else
{
followerCount
=
new
Double
(
aDouble
).
longValue
();
}
else
if
(
followers_count
.
contains
(
"亿"
)){
String
[]
split
=
followers_count
.
split
(
"亿"
);
Double
aDouble
=
Double
.
valueOf
(
split
[
0
])*
100000000
;
followerCount
=
new
Double
(
aDouble
).
longValue
();
}
else
{
followerCount
=
Long
.
valueOf
(
followers_count
);
followerCount
=
Long
.
valueOf
(
followers_count
);
}
}
//用户头像地址
//用户头像地址
...
...
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
View file @
ab081ccd
...
@@ -50,6 +50,9 @@ public class HotSearchCacheDAO {
...
@@ -50,6 +50,9 @@ public class HotSearchCacheDAO {
document
.
put
(
"topic_lead"
,
hotSearch
.
getTopicLead
());
document
.
put
(
"topic_lead"
,
hotSearch
.
getTopicLead
());
document
.
put
(
"comment_count"
,
hotSearch
.
getCommentCount
());
document
.
put
(
"comment_count"
,
hotSearch
.
getCommentCount
());
}
}
if
(
"微博热搜"
.
equals
(
hotSearch
.
getType
())){
document
.
put
(
"iconUrl"
,
hotSearch
.
getIconUrl
());
}
// if("今日头条热搜".equals(hotSearch.getType())){
// if("今日头条热搜".equals(hotSearch.getType())){
// document.put("comment_count", hotSearch.getCommentCount());
// document.put("comment_count", hotSearch.getCommentCount());
// }
// }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment