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
c6199334
Commit
c6199334
authored
May 14, 2018
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
知乎添加移動端的榜單採集
parent
af14ca7b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletions
+55
-1
src/main/java/com/zhiwei/searchhotcrawler/crawler/ZhihuHotSearchCrawler.java
+54
-0
src/main/java/com/zhiwei/searchhotcrawler/run/HotSearchRun.java
+1
-1
No files found.
src/main/java/com/zhiwei/searchhotcrawler/crawler/ZhihuHotSearchCrawler.java
View file @
c6199334
...
...
@@ -73,4 +73,58 @@ public class ZhihuHotSearchCrawler {
}
return
list
;
}
/**
* @Title: getMobileZhihuHotList
* @author hero
* @Description: 移動端知乎熱搜榜
* @param @return 设定文件
* @return List<ZhihuHotSearch> 返回类型
*/
public
static
List
<
ZhihuHotSearch
>
getMobileZhihuHotList
(){
List
<
ZhihuHotSearch
>
list
=
null
;
String
url
=
"https://api.zhihu.com/topstory/hot-list?limit=40&reverse_order=0"
;
Map
<
String
,
String
>
headerMap
=
HeaderTool
.
getCommonHead
();
headerMap
.
put
(
"Host"
,
"api.zhihu.com"
);
headerMap
.
put
(
"Referer"
,
url
);
headerMap
.
put
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"
);
headerMap
.
put
(
"X-UDID"
,
"AFAC3hv3vgyPTt9ZmNmqTm0yv_8NKY3S3z8="
);
headerMap
.
put
(
"authorization"
,
"oauth c3cef7c66a1843f8b3a9e6a1e3160e20"
);
for
(
int
j
=
0
;
j
<
3
;
j
++){
try
{
System
.
out
.
println
(
url
);
String
htmlBody
=
HttpClientTemplateOK
.
get
(
url
,
null
,
headerMap
);
System
.
out
.
println
(
htmlBody
);
if
(
htmlBody
!=
null
){
if
(
htmlBody
.
contains
(
"author"
)){
list
=
new
ArrayList
<
ZhihuHotSearch
>();
JSONObject
top_search
=
JSONObject
.
parseObject
(
htmlBody
);
JSONArray
words
=
top_search
.
getJSONArray
(
"data"
);
String
link
=
null
;
String
display_query
=
null
;
String
query
=
null
;
for
(
int
i
=
0
;
i
<
words
.
size
();
i
++)
{
JSONObject
word
=
words
.
getJSONObject
(
i
).
getJSONObject
(
"target"
);
query
=
word
.
getString
(
"title"
);
display_query
=
word
.
getString
(
"title"
);
link
=
"https://www.zhihu.com/question/"
+
word
.
getLongValue
(
"id"
);
ZhihuHotSearch
zhihu
=
new
ZhihuHotSearch
(
link
,
query
,
display_query
,
new
Date
());
System
.
out
.
println
(
zhihu
);
list
.
add
(
zhihu
);
}
break
;
}
else
{
System
.
out
.
println
(
"---------------"
);
}
}
}
catch
(
IOException
e
)
{
logger
.
debug
(
"获取知乎热搜时出现问题:{}"
,
e
.
fillInStackTrace
());
continue
;
}
}
return
list
;
}
}
src/main/java/com/zhiwei/searchhotcrawler/run/HotSearchRun.java
View file @
c6199334
...
...
@@ -16,7 +16,7 @@ public class HotSearchRun {
private
ScheduledExecutorService
scheduExec
;
public
HotSearchRun
()
{
this
.
scheduExec
=
Executors
.
newScheduledThreadPool
(
4
);
this
.
scheduExec
=
Executors
.
newScheduledThreadPool
(
1
);
}
public
void
showTimer
()
{
...
...
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