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
4987c3f7
Commit
4987c3f7
authored
Sep 29, 2022
by
leiliangliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
搜狗微信热搜采集程序更新
parent
e4f4c636
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
32 deletions
+12
-32
src/main/java/com/zhiwei/searchhotcrawler/crawler/SougoHotSearchCrawler.java
+12
-32
No files found.
src/main/java/com/zhiwei/searchhotcrawler/crawler/SougoHotSearchCrawler.java
View file @
4987c3f7
...
@@ -40,10 +40,10 @@ public class SougoHotSearchCrawler {
...
@@ -40,10 +40,10 @@ public class SougoHotSearchCrawler {
* @return void 返回类型
* @return void 返回类型
*/
*/
public
static
List
<
HotSearchList
>
sougoHotSearch
(
Date
date
)
{
public
static
List
<
HotSearchList
>
sougoHotSearch
(
Date
date
)
{
String
url
=
"https://weixin.sogou.com"
;
//String url = "https://weixin.sogou.com";
String
url
=
"https://weixin.sogou.com/pcindex/pc/web/web.js?"
;
List
<
HotSearchList
>
list
=
new
ArrayList
<>();
List
<
HotSearchList
>
list
=
new
ArrayList
<>();
Map
<
String
,
String
>
headMap
=
HeaderTool
.
getCommonHead
();
Request
request
=
RequestUtils
.
wrapGet
(
url
);
Request
request
=
RequestUtils
.
wrapGet
(
url
,
headMap
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
String
htmlBody
=
null
;
String
htmlBody
=
null
;
Response
response
=
httpBoot
.
syncCall
(
request
,
ProxySupplier
.
NAT_HEAVY_PROXY
);
Response
response
=
httpBoot
.
syncCall
(
request
,
ProxySupplier
.
NAT_HEAVY_PROXY
);
...
@@ -55,35 +55,15 @@ public class SougoHotSearchCrawler {
...
@@ -55,35 +55,15 @@ public class SougoHotSearchCrawler {
}
}
if
(
htmlBody
!=
null
&&
htmlBody
.
contains
(
"topwords"
))
{
if
(
htmlBody
!=
null
&&
htmlBody
.
contains
(
"topwords"
))
{
try
{
try
{
Document
document
=
Jsoup
.
parse
(
htmlBody
);
int
rank
=
0
;
Elements
elements
=
document
.
select
(
"ol#topwords"
).
select
(
"li"
);
JSONArray
jsonArray
=
JSONObject
.
parseObject
(
htmlBody
).
getJSONArray
(
"topwords"
);
for
(
Element
element
:
elements
)
{
for
(
Object
object
:
jsonArray
)
{
try
{
rank
++;
// 获取排名rank
JSONObject
json
=
(
JSONObject
)
JSONObject
.
toJSON
(
object
);
String
rankStr
=
null
;
String
kw
=
json
.
getString
(
"word"
);
if
(!
element
.
select
(
"li"
).
select
(
"i"
).
isEmpty
())
{
String
everurl
=
"https://weixin.sogou.com/weixin?type=2&query="
+
kw
;
rankStr
=
element
.
select
(
"li"
).
select
(
"i"
).
text
();
HotSearchList
hotSearch
=
new
HotSearchList
(
everurl
,
kw
,
null
,
rank
,
HotSearchType
.
搜狗微信热搜
.
name
(),
date
);
}
list
.
add
(
hotSearch
);
Integer
rank
=
null
;
if
(
StringUtils
.
isNoneBlank
(
rankStr
))
{
rank
=
Integer
.
valueOf
(
rankStr
);
}
// 获取关键词(String)
String
kw
=
element
.
select
(
"li"
).
select
(
"a"
).
attr
(
"title"
);
// log.info("关键词:{}", kw);
String
everurl
=
element
.
select
(
"li"
).
select
(
"a"
).
attr
(
"href"
);
HotSearchList
hotSearch
=
new
HotSearchList
(
everurl
,
kw
,
null
,
rank
,
HotSearchType
.
搜狗微信热搜
.
name
(),
date
);
if
(
Objects
.
nonNull
(
rank
))
{
list
.
add
(
hotSearch
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"解析搜狗微信时出现解析错误"
,
e
);
}
}
}
break
;
break
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
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