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
5b2136e2
Commit
5b2136e2
authored
Nov 19, 2019
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微博热搜添加区分推荐位icon字段
parent
ae0a5009
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
+7
-5
No files found.
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
View file @
5b2136e2
...
@@ -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
++;
...
...
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