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
d3049158
Commit
d3049158
authored
Feb 02, 2021
by
马黎滨
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mlb-template-local' into 'mlbWork'
B站全日榜图片信息添加 See merge request
!71
parents
da89439e
d231d355
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
src/main/java/com/zhiwei/searchhotcrawler/bean/HotSearchList.java
+7
-1
src/main/java/com/zhiwei/searchhotcrawler/crawler/BililiCrawler.java
+2
-1
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
+14
-4
No files found.
src/main/java/com/zhiwei/searchhotcrawler/bean/HotSearchList.java
View file @
d3049158
...
...
@@ -94,6 +94,11 @@ public class HotSearchList implements Serializable{
*/
private
Integer
barrage
;
/**
* 图片地址
*/
private
String
pictureUrl
;
public
HotSearchList
(){}
public
HotSearchList
(
String
url
,
String
name
,
Integer
count
,
Boolean
hot
,
Integer
rank
,
String
type
,
String
icon
,
Date
date
){
...
...
@@ -151,7 +156,7 @@ public class HotSearchList implements Serializable{
this
.
topicResult
=
topicResult
;
}
public
HotSearchList
(
String
url
,
String
name
,
String
topicLead
,
Integer
count
,
Boolean
hot
,
Date
time
,
Integer
rank
,
String
type
,
Integer
view
,
Integer
barrage
)
{
public
HotSearchList
(
String
url
,
String
name
,
String
topicLead
,
Integer
count
,
Boolean
hot
,
Date
time
,
Integer
rank
,
String
type
,
Integer
view
,
Integer
barrage
,
String
pictureUrl
)
{
this
.
id
=
name
+
"_"
+
new
Date
().
getTime
()+
"_"
+
type
;
this
.
url
=
url
;
this
.
name
=
name
;
...
...
@@ -164,5 +169,6 @@ public class HotSearchList implements Serializable{
this
.
type
=
type
;
this
.
view
=
view
;
this
.
barrage
=
barrage
;
this
.
pictureUrl
=
pictureUrl
;
}
}
src/main/java/com/zhiwei/searchhotcrawler/crawler/BililiCrawler.java
View file @
d3049158
...
...
@@ -54,6 +54,7 @@ public class BililiCrawler {
String
topicLead
=
data
.
getString
(
"desc"
);
int
count
=
data
.
getIntValue
(
"score"
);
String
bvid
=
data
.
getString
(
"bvid"
);
String
pic
=
data
.
getString
(
"pic"
);
String
bUrl
=
"https://www.bilibili.com/video/"
+
bvid
;
Integer
view
=
null
;
Integer
barrage
=
null
;
...
...
@@ -62,7 +63,7 @@ public class BililiCrawler {
view
=
stat
.
getIntValue
(
"view"
);
barrage
=
stat
.
getIntValue
(
"danmaku"
);
}
HotSearchList
hotSearchList
=
new
HotSearchList
(
bUrl
,
name
,
topicLead
,
count
,
null
,
date
,
rank
,
HotSearchType
.
B
站排行榜
.
name
(),
view
,
barrage
);
HotSearchList
hotSearchList
=
new
HotSearchList
(
bUrl
,
name
,
topicLead
,
count
,
null
,
date
,
rank
,
HotSearchType
.
B
站排行榜
.
name
(),
view
,
barrage
,
pic
);
hotSearchLists
.
add
(
hotSearchList
);
}
}
...
...
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
View file @
d3049158
...
...
@@ -12,10 +12,7 @@ import lombok.extern.log4j.Log4j2;
import
org.apache.logging.log4j.util.Strings
;
import
org.bson.Document
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.*
;
/**
* 热搜基础结果表
...
...
@@ -25,6 +22,7 @@ public class HotSearchCacheDAO {
private
static
MongoCollection
collection
=
MongoDBTemplate
.
getCollection
(
DBConfig
.
dbName
,
DBConfig
.
searchCacheCollName
);
private
static
List
<
String
>
picTypes
=
Arrays
.
asList
(
"B站排行榜"
);
/**
* 存储数据
...
...
@@ -59,6 +57,7 @@ public class HotSearchCacheDAO {
document
.
put
(
"topic_lead"
,
hotSearch
.
getTopicLead
());
document
.
put
(
"view"
,
hotSearch
.
getView
());
document
.
put
(
"barrage"
,
hotSearch
.
getBarrage
());
document
.
put
(
"pictureUrl"
,
hotSearch
.
getPictureUrl
());
}
addAndUpdateData
(
document
);
dataes
.
add
(
document
);
...
...
@@ -86,6 +85,7 @@ public class HotSearchCacheDAO {
boolean
hot
=
document
.
getBoolean
(
"hot"
)!=
null
?
document
.
getBoolean
(
"hot"
):
true
;
String
url
=
document
.
getString
(
"url"
)!=
null
?
document
.
getString
(
"url"
):
null
;
String
topicResult
=
document
.
getString
(
"topic_result"
)!=
null
?
document
.
getString
(
"topic_result"
):
null
;
String
pictureUrl
=
document
.
getString
(
"pictureUrl"
)!=
null
?
document
.
getString
(
"pictureUrl"
):
null
;
String
id
=
name
+
"_"
+
type
;
boolean
recommend
=
false
;
// Integer readCount = document.getInteger("comment_count");
...
...
@@ -147,6 +147,13 @@ public class HotSearchCacheDAO {
if
(
topicResult
!=
null
){
nowDoc
.
put
(
"topicResult"
,
topicResult
);
}
if
(
picTypes
.
contains
(
type
)){
if
(
Strings
.
isNotEmpty
(
pictureUrl
)){
if
(!
nowDoc
.
containsKey
(
"pictureUrl"
)
||
!
nowDoc
.
getString
(
"pictureUrl"
).
equals
(
pictureUrl
))
{
nowDoc
.
put
(
"pictureUrl"
,
pictureUrl
);
}
}
}
collection
.
replaceOne
(
query
,
nowDoc
);
}
else
{
nowDoc
=
new
Document
();
...
...
@@ -175,6 +182,9 @@ public class HotSearchCacheDAO {
if
(
topicResult
!=
null
){
nowDoc
.
put
(
"topicResult"
,
topicResult
);
}
if
(
picTypes
.
contains
(
type
)){
nowDoc
.
put
(
"pictureUrl"
,
pictureUrl
);
}
if
(
"微博热搜"
.
equals
(
type
)){
nowDoc
=
WeiboHotSearchCrawler
.
weiboUpdate
(
nowDoc
);
if
(
nowDoc
.
containsKey
(
"topicLead"
)){
...
...
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