Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
toutiao
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
toutiao
Commits
061bc022
Commit
061bc022
authored
Dec 19, 2019
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交新的js加密参数
parent
048700cc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
src/main/java/com/zhiwei/toutiao/parse/TouTiaoArticleParse.java
+17
-11
src/main/resources/signature.js
+10
-6
No files found.
src/main/java/com/zhiwei/toutiao/parse/TouTiaoArticleParse.java
View file @
061bc022
...
@@ -117,8 +117,8 @@ public class TouTiaoArticleParse {
...
@@ -117,8 +117,8 @@ public class TouTiaoArticleParse {
/**
/**
* 获取今日头条历史文章接口新
* 获取今日头条历史文章接口新
*
*
* @param user
_i
d
* @param user
I
d
* @param max
_behot_t
ime
* @param max
BehotT
ime
* @param endData
* @param endData
* @param proxy
* @param proxy
* @return
* @return
...
@@ -353,12 +353,15 @@ public class TouTiaoArticleParse {
...
@@ -353,12 +353,15 @@ public class TouTiaoArticleParse {
*/
*/
public
static
Map
<
String
,
Object
>
getMicroTouTiaoCrawler
(
String
userId
,
Date
endDate
,
Proxy
proxy
,
public
static
Map
<
String
,
Object
>
getMicroTouTiaoCrawler
(
String
userId
,
Date
endDate
,
Proxy
proxy
,
String
maxBehotTime
)
throws
IOException
{
String
maxBehotTime
)
throws
IOException
{
String
url
=
"https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id="
+
userId
;
Signature
signature
=
new
Signature
(
userId
,
maxBehotTime
);
if
(
maxBehotTime
!=
null
)
{
String
signatureStr
=
signature
.
getSignature
();
url
=
url
+
"&max_behot_time="
+
maxBehotTime
;
if
(
StringUtils
.
isBlank
(
maxBehotTime
))
{
maxBehotTime
=
"0"
;
}
}
String
url
=
"https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id="
+
userId
+
"&max_behot_time="
+
maxBehotTime
+
"&_signature="
+
signatureStr
;
System
.
out
.
println
(
url
);
System
.
out
.
println
(
url
);
Map
<
String
,
String
>
headerMap
=
Tools
.
getTouTiaoHeader
();
Map
<
String
,
String
>
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
.
put
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
);
headerMap
.
put
(
"Referer"
,
"https://www.toutiao.com/c/user/"
+
userId
+
"/"
);
headerMap
.
put
(
"Referer"
,
"https://www.toutiao.com/c/user/"
+
userId
+
"/"
);
try
{
try
{
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
...
@@ -379,10 +382,13 @@ public class TouTiaoArticleParse {
...
@@ -379,10 +382,13 @@ public class TouTiaoArticleParse {
public
static
Map
<
String
,
Object
>
getMicroTouTiaoCrawler
(
String
userId
,
Date
endDate
,
ProxyHolder
proxy
,
public
static
Map
<
String
,
Object
>
getMicroTouTiaoCrawler
(
String
userId
,
Date
endDate
,
ProxyHolder
proxy
,
Long
maxBehotTime
)
throws
IOException
{
Long
maxBehotTime
)
throws
IOException
{
String
url
=
"https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id="
+
userId
;
Signature
signature
=
new
Signature
(
String
.
valueOf
(
userId
),
String
.
valueOf
(
maxBehotTime
));
if
(
maxBehotTime
!=
null
)
{
String
signatureStr
=
signature
.
getSignature
();
url
=
url
+
"&max_behot_time="
+
maxBehotTime
;
if
(
Objects
.
isNull
(
maxBehotTime
))
{
maxBehotTime
=
0L
;
}
}
String
url
=
"https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id="
+
userId
+
"&max_behot_time="
+
maxBehotTime
+
"&_signature="
+
signatureStr
;
System
.
out
.
println
(
url
);
logger
.
info
(
"微头条采集链接:::{}"
,
url
);
logger
.
info
(
"微头条采集链接:::{}"
,
url
);
Map
<
String
,
String
>
headerMap
=
Tools
.
getTouTiaoHeader
();
Map
<
String
,
String
>
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
.
put
(
"Referer"
,
"https://www.toutiao.com/c/user/"
+
userId
+
"/"
);
headerMap
.
put
(
"Referer"
,
"https://www.toutiao.com/c/user/"
+
userId
+
"/"
);
...
@@ -407,9 +413,8 @@ public class TouTiaoArticleParse {
...
@@ -407,9 +413,8 @@ public class TouTiaoArticleParse {
*
*
* @Description 微头条客户端解析
* @Description 微头条客户端解析
* @param userId
* @param userId
* @param endDate
* @param proxy
* @param proxy
* @param max
_behot_t
ime
* @param max
BehotT
ime
* @return
* @return
*/
*/
public
static
List
<
Map
<
String
,
Object
>>
getClientMicroToutiaoCrawler
(
String
userId
,
ProxyHolder
proxy
,
public
static
List
<
Map
<
String
,
Object
>>
getClientMicroToutiaoCrawler
(
String
userId
,
ProxyHolder
proxy
,
...
@@ -487,6 +492,7 @@ public class TouTiaoArticleParse {
...
@@ -487,6 +492,7 @@ public class TouTiaoArticleParse {
Long
maxBehotTime
=
null
;
Long
maxBehotTime
=
null
;
List
<
TouTiaoArticle
>
dataList
=
new
ArrayList
<>();
List
<
TouTiaoArticle
>
dataList
=
new
ArrayList
<>();
try
{
try
{
System
.
out
.
println
(
"htmlBody====="
+
htmlBody
);
JSONObject
json
=
JSONObject
.
parseObject
(
htmlBody
);
JSONObject
json
=
JSONObject
.
parseObject
(
htmlBody
);
boolean
more
=
false
;
boolean
more
=
false
;
if
(
json
.
containsKey
(
"has_more"
))
{
if
(
json
.
containsKey
(
"has_more"
))
{
...
@@ -726,7 +732,7 @@ public class TouTiaoArticleParse {
...
@@ -726,7 +732,7 @@ public class TouTiaoArticleParse {
if
(
proxy
!=
null
)
{
if
(
proxy
!=
null
)
{
response
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headMap
),
proxy
);
response
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headMap
),
proxy
);
}
else
{
}
else
{
response
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headMap
)
,
ProxyHolder
.
NAT_HEAVY_PROXY
);
response
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headMap
));
}
}
return
response
.
body
().
string
();
return
response
.
body
().
string
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/resources/signature.js
View file @
061bc022
No preview for this file type
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