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
267df575
Commit
267df575
authored
Mar 18, 2019
by
[zhangzhiwei]
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微博添加排名字段
parent
aec57a25
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
src/main/java/com/zhiwei/searchhotcrawler/bean/WeiboHotSearch.java
+12
-1
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
+6
-2
src/main/java/com/zhiwei/searchhotcrawler/timer/WeiboHotSearchRun.java
+1
-0
No files found.
src/main/java/com/zhiwei/searchhotcrawler/bean/WeiboHotSearch.java
View file @
267df575
...
...
@@ -32,16 +32,18 @@ public class WeiboHotSearch implements Serializable{
private
int
changeCount
;
//据上分钟变化量
private
int
rank
;
//排名
public
WeiboHotSearch
(){}
public
WeiboHotSearch
(
String
url
,
String
name
,
int
count
,
boolean
hot
){
public
WeiboHotSearch
(
String
url
,
String
name
,
int
count
,
boolean
hot
,
int
rank
){
this
.
id
=
name
+
"_"
+
new
Date
().
getTime
();
this
.
url
=
url
;
this
.
name
=
name
;
this
.
count
=
count
;
this
.
hot
=
hot
;
this
.
rank
=
rank
;
this
.
time
=
new
Date
();
this
.
day
=
TimeParse
.
dateFormartString
(
new
Date
(),
"yyyy-MM-dd"
);
}
...
...
@@ -56,6 +58,7 @@ public class WeiboHotSearch implements Serializable{
+
", count = "
+
count
+
", time = "
+
time
+
", hot = "
+
hot
+
", rank = "
+
rank
+
", day = "
+
day
+
", changeCount = "
+
changeCount
+
"]"
;
...
...
@@ -130,6 +133,14 @@ public class WeiboHotSearch implements Serializable{
this
.
day
=
day
;
}
public
int
getRank
()
{
return
rank
;
}
public
void
setRank
(
int
rank
)
{
this
.
rank
=
rank
;
}
...
...
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
View file @
267df575
...
...
@@ -66,8 +66,11 @@ public class WeiboHotSearchCrawler {
String
id
=
"http://s.weibo.com"
+
element
.
select
(
"td.td-02"
).
select
(
"a"
).
attr
(
"href"
);
String
name
=
element
.
select
(
"td.td-02"
).
select
(
"a"
).
text
();
String
num
=
!
element
.
select
(
"td.td-02"
).
select
(
"span"
).
text
().
equals
(
""
)?
element
.
select
(
"td.td-02"
).
select
(
"span"
).
text
():
"0"
;
String
rank
=
!
element
.
select
(
"td[class=\"td-01 ranktop\"]"
).
text
().
equals
(
""
)?
element
.
select
(
"td[class=\"td-01 ranktop\"]"
).
text
():
"-1"
;
int
hotCount
=
Integer
.
valueOf
(
num
);
WeiboHotSearch
hotSearch
=
new
WeiboHotSearch
(
id
,
name
,
hotCount
,
true
);
int
rankCount
=
Integer
.
valueOf
(
rank
);
WeiboHotSearch
hotSearch
=
new
WeiboHotSearch
(
id
,
name
,
hotCount
,
true
,
rankCount
);
list
.
add
(
hotSearch
);
}
catch
(
Exception
e
)
{
SendMailWeibo
.
sendMail
(
"微博热搜采集出现问题"
,
"859548429@qq.com"
);
...
...
@@ -134,9 +137,10 @@ public class WeiboHotSearchCrawler {
JSONObject
cardInfo
=
card_group
.
getJSONObject
(
j
);
String
name
=
cardInfo
.
getString
(
"desc"
);
int
hotCount
=
cardInfo
.
getIntValue
(
"desc_extr"
);
int
rankCount
=
cardInfo
.
getIntValue
(
"desc_extr"
);
String
id
=
"http://s.weibo.com/weibo/"
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)
+
"&Refer=top"
;
WeiboHotSearch
hotSearch
=
new
WeiboHotSearch
(
id
,
name
,
hotCount
,
hot
);
WeiboHotSearch
hotSearch
=
new
WeiboHotSearch
(
id
,
name
,
hotCount
,
hot
,
rankCount
);
logger
.
info
(
"采集到的数据:::{}"
,
hotSearch
);
result
.
add
(
hotSearch
);
}
...
...
src/main/java/com/zhiwei/searchhotcrawler/timer/WeiboHotSearchRun.java
View file @
267df575
...
...
@@ -35,6 +35,7 @@ public class WeiboHotSearchRun extends Thread{
doc
.
put
(
"day"
,
weiboHotSearch
.
getDay
());
doc
.
put
(
"time"
,
weiboHotSearch
.
getTime
());
doc
.
put
(
"changeCount"
,
changeCount
);
doc
.
put
(
"rank"
,
weiboHotSearch
.
getRank
());
data
.
add
(
doc
);
}
weiboHotSearchDAO
.
addWeiboHotSearch
(
data
);
...
...
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