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
f061889a
Commit
f061889a
authored
Jun 25, 2018
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理账号匹配规则
parent
eedbd670
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
+5
-10
No files found.
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
View file @
f061889a
...
...
@@ -44,13 +44,13 @@ public class TouTiaoAccountParse {
try
{
String
htmlBody
=
null
;
htmlBody
=
HttpClientTemplateOK
.
get
(
url
,
proxy
,
headerMap
);
if
(
htmlBody
!=
null
&&
htmlBody
.
contains
(
"media_id"
)
){
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
=
HttpClientTemplateOK
.
get
(
url
,
proxy
,
headerMap
);
if
(
htmlBody
!=
null
&&
htmlBody
.
contains
(
"media_id"
)
){
if
(
htmlBody
!=
null
){
tta
=
parseHtmlByAccount
(
htmlBody
,
name
,
proxy
);
}
}
...
...
@@ -58,7 +58,7 @@ public class TouTiaoAccountParse {
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
=
HttpClientTemplateOK
.
get
(
url
,
proxy
,
headerMap
);
if
(
htmlBody
!=
null
&&
htmlBody
.
contains
(
"media_id"
)
){
if
(
htmlBody
!=
null
){
tta
=
parseHtmlByAccount
(
htmlBody
,
name
,
proxy
);
}
}
...
...
@@ -79,7 +79,7 @@ public class TouTiaoAccountParse {
try
{
String
htmlBody
=
null
;
htmlBody
=
HttpClientTemplateOK
.
get
(
url
,
proxy
,
headerMap
);
if
(
htmlBody
!=
null
&&
htmlBody
.
contains
(
"mediaId"
)
){
if
(
htmlBody
!=
null
){
tta
=
parseAccountByUserId
(
htmlBody
,
user_id
);
}
...
...
@@ -113,7 +113,7 @@ public class TouTiaoAccountParse {
try
{
String
htmlBody
=
null
;
htmlBody
=
HttpClientTemplateOK
.
get
(
url
,
proxy
,
headerMap
);
if
(
htmlBody
!=
null
&&
htmlBody
.
contains
(
"media_id"
)
){
if
(
htmlBody
!=
null
){
JSONObject
json
=
JSONObject
.
parseObject
(
htmlBody
);
list
.
addAll
(
parseHtmlByWord
(
json
,
proxy
));
if
(
json
.
getIntValue
(
"has_more"
)==
0
){
...
...
@@ -192,9 +192,7 @@ public class TouTiaoAccountParse {
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
try
{
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
if
(
data
.
containsKey
(
"media_id"
)){
long
user_id
=
data
.
getLong
(
"id"
);
String
name
=
data
.
getString
(
"name"
);
long
media_id
=
data
.
getLong
(
"media_id"
);
...
...
@@ -218,7 +216,6 @@ public class TouTiaoAccountParse {
}
return
tta
;
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
continue
;
...
...
@@ -299,7 +296,6 @@ public class TouTiaoAccountParse {
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
try
{
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
if
(
data
.
containsKey
(
"media_id"
)){
user_id
=
data
.
getLong
(
"id"
);
name
=
data
.
getString
(
"name"
);
media_id
=
data
.
getLong
(
"media_id"
);
...
...
@@ -321,7 +317,6 @@ public class TouTiaoAccountParse {
tta
.
setUser_type
(
ttaUpdate
.
getUser_type
());
}
ttaList
.
add
(
tta
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
continue
;
...
...
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