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
5ade0fda
Commit
5ade0fda
authored
Feb 14, 2019
by
yangchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 头条用户信息更新失效bug
parent
b439fe28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
+8
-13
No files found.
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
View file @
5ade0fda
...
...
@@ -5,6 +5,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -42,24 +43,15 @@ public class TouTiaoAccountParse {
* @return TouTiaoAccount 返回类型
*/
public
static
TouTiaoAccount
getTouTiaoAccountInfoByName
(
String
name
,
Proxy
proxy
){
String
url
=
"https://www.toutiao.com/
search_content/?offset=0&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&autoload=true&count=20&cur_tab=1
"
;
String
url
=
"https://www.toutiao.com/
api/search/content/?aid=24&offset=0&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&autoload=true&count=20&cur_tab=4&from=media&pd=user
"
;
headerMap
=
Tools
.
getTouTiaoHeader
();
TouTiaoAccount
tta
=
null
;
try
{
String
htmlBody
=
null
;
htmlBody
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headerMap
),
proxy
).
body
().
string
();
if
(
htmlBody
!=
null
){
tta
=
parseHtmlByAccount
(
htmlBody
,
name
,
proxy
);
if
(
tta
==
null
){
url
=
"https://www.toutiao.com/search_content/?offset=0&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&autoload=true&count=20&cur_tab=4&from=media"
;
headerMap
.
put
(
"Referer"
,
"https://www.toutiao.com/search/?keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
));
htmlBody
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headerMap
),
proxy
).
body
().
string
();
if
(
htmlBody
!=
null
){
tta
=
parseHtmlByAccount
(
htmlBody
,
name
,
proxy
);
}
}
}
else
{
url
=
"https://www.toutiao.com/search_content/?offset=0&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&autoload=true&count=20&cur_tab=4&from=media"
;
tta
=
parseHtmlByAccount
(
htmlBody
,
name
,
proxy
);
if
(
tta
==
null
){
url
=
"https://www.toutiao.com/api/search/content/?aid=24&offset=0&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&autoload=true&count=20&cur_tab=1&from=search_tab&pd=synthesis"
;
headerMap
.
put
(
"Referer"
,
"https://www.toutiao.com/search/?keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
));
htmlBody
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headerMap
),
proxy
).
body
().
string
();
if
(
htmlBody
!=
null
){
...
...
@@ -231,6 +223,9 @@ public class TouTiaoAccountParse {
*/
private
static
TouTiaoAccount
parseHtmlByAccount
(
String
htmlBody
,
String
word
,
Proxy
proxy
)
{
try
{
if
(
Objects
.
isNull
(
htmlBody
))
{
return
null
;
}
JSONObject
json
=
JSONObject
.
parseObject
(
htmlBody
);
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
Long
user_id
=
null
;
...
...
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