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
d7da84ad
Commit
d7da84ad
authored
Jul 16, 2019
by
[zhangzhiwei]
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加今日头条账号认证类型及是否认证
parent
9db65425
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
248 additions
and
198 deletions
+248
-198
pom.xml
+1
-1
src/main/java/com/zhiwei/toutiao/bean/TouTiaoAccount.java
+122
-84
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
+125
-113
No files found.
pom.xml
View file @
d7da84ad
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.zhiwei
</groupId>
<groupId>
com.zhiwei
</groupId>
<artifactId>
toutiao
</artifactId>
<artifactId>
toutiao
</artifactId>
<version>
0.3.
5
-SNAPSHOT
</version>
<version>
0.3.
6
-SNAPSHOT
</version>
<dependencies>
<dependencies>
<dependency>
<dependency>
...
...
src/main/java/com/zhiwei/toutiao/bean/TouTiaoAccount.java
View file @
d7da84ad
...
@@ -15,168 +15,201 @@ public class TouTiaoAccount implements Serializable{
...
@@ -15,168 +15,201 @@ public class TouTiaoAccount implements Serializable{
public
String
id
;
//主键 帐号id
public
String
id
;
//主键 帐号id
public
Long
user
_i
d
;
//帐号id
public
Long
user
I
d
;
//帐号id
public
String
name
;
//帐号昵称
public
String
name
;
//帐号昵称
public
Long
media
_i
d
;
//未知
public
Long
media
I
d
;
//未知
public
String
description
;
//描述
public
String
description
;
//描述
public
Integer
user
_v
erified
;
//是否认证 (0,不是;1 是)
public
Integer
user
V
erified
;
//是否认证 (0,不是;1 是)
public
String
verify
_c
ontent
;
//认证原因
public
String
verify
C
ontent
;
//认证原因
public
Integer
follow
_c
ount
;
//粉丝数
public
Integer
follow
C
ount
;
//粉丝数
public
Integer
friend
_c
ount
;
//关注数
public
Integer
friend
C
ount
;
//关注数
public
String
img
_u
rl
;
//头像地址
public
String
img
U
rl
;
//头像地址
public
Date
create
_t
ime
;
//账号注册时间
public
Date
create
T
ime
;
//账号注册时间
public
String
gender
;
//性别
public
String
gender
;
//性别
public
String
user_type
;
//用户类型
public
Integer
userType
;
//用户类型
public
Integer
authType
;
//用户认证类型
public
Boolean
isDv
;
//是否加V
@Override
@Override
public
String
toString
(){
public
String
toString
(){
return
"new TouTiaoAccount["
return
"new TouTiaoAccount["
+
"id = "
+
id
+
"id = "
+
id
+
", user
_id = "
+
user_i
d
+
", user
Id = "
+
userI
d
+
", name = "
+
name
+
", name = "
+
name
+
",
media_id = "
+
media_i
d
+
",
userId = "
+
userI
d
+
", description = "
+
description
+
", description = "
+
description
+
", user
_verified = "
+
user_v
erified
+
", user
Verified = "
+
userV
erified
+
", verify
_content = "
+
verify_c
ontent
+
", verify
Content = "
+
verifyC
ontent
+
", follow
_count = "
+
follow_c
ount
+
", follow
Count = "
+
followC
ount
+
", friend
_count = "
+
friend_c
ount
+
", friend
Count = "
+
friendC
ount
+
", img
_url = "
+
img_u
rl
+
", img
Url = "
+
imgU
rl
+
", create
_time = "
+
create_t
ime
+
", create
Time = "
+
createT
ime
+
", gender = "
+
gender
+
", gender = "
+
gender
+
", user_type = "
+
user_type
+
", userType = "
+
userType
+
", authType = "
+
authType
+
", isDv = "
+
isDv
+
"]"
;
+
"]"
;
}
}
public
TouTiaoAccount
(){}
public
TouTiaoAccount
(){}
public
TouTiaoAccount
(
Long
user
_id
,
String
name
,
Long
media_id
,
String
description
,
Integer
user_v
erified
public
TouTiaoAccount
(
Long
user
Id
,
String
name
,
Long
mediaId
,
String
description
,
Integer
userV
erified
,
String
verify
_content
,
Integer
follow_count
,
String
img_url
,
Date
create_t
ime
,
String
gender
,
String
verify
Content
,
Integer
followCount
,
String
imgUrl
,
Date
createT
ime
,
String
gender
,
String
user_type
){
,
Integer
userType
,
Integer
authType
,
Boolean
isDv
){
this
.
id
=
user_id
+
""
;
this
.
id
=
String
.
valueOf
(
userId
)
;
this
.
user
_id
=
user_i
d
;
this
.
user
Id
=
userI
d
;
this
.
name
=
name
;
this
.
name
=
name
;
this
.
media
_id
=
media_i
d
;
this
.
media
Id
=
mediaI
d
;
this
.
description
=
description
;
this
.
description
=
description
;
this
.
user
_verified
=
user_v
erified
;
this
.
user
Verified
=
userV
erified
;
this
.
verify
_content
=
verify_c
ontent
;
this
.
verify
Content
=
verifyC
ontent
;
this
.
follow
_count
=
follow_c
ount
;
this
.
follow
Count
=
followC
ount
;
this
.
img
_url
=
img_u
rl
;
this
.
img
Url
=
imgU
rl
;
this
.
create
_time
=
create_t
ime
;
this
.
create
Time
=
createT
ime
;
this
.
gender
=
gender
;
this
.
gender
=
gender
;
this
.
user_type
=
user_type
;
this
.
userType
=
userType
;
this
.
authType
=
authType
;
this
.
isDv
=
isDv
;
}
}
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
Long
getUser
_i
d
()
{
public
Long
getUser
I
d
()
{
return
user
_i
d
;
return
user
I
d
;
}
}
public
void
setUser_id
(
Long
user_id
)
{
this
.
user_id
=
user_id
;
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Long
getMedia
_i
d
()
{
public
Long
getMedia
I
d
()
{
return
media
_i
d
;
return
media
I
d
;
}
}
public
void
setMedia_id
(
Long
media_id
)
{
this
.
media_id
=
media_id
;
}
public
String
getDescription
()
{
public
String
getDescription
()
{
return
description
;
return
description
;
}
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
public
Integer
getUserVerified
()
{
return
userVerified
;
}
}
public
Integer
getUser_verified
()
{
return
user_verified
;
public
String
getVerifyContent
()
{
return
verifyContent
;
}
}
public
void
setUser_verified
(
Integer
user_verified
)
{
this
.
user_verified
=
user_verified
;
public
Integer
getFollowCount
()
{
return
followCount
;
}
}
public
Integer
getFollow_count
()
{
return
follow_count
;
public
Integer
getFriendCount
()
{
return
friendCount
;
}
}
public
void
setFollow_count
(
Integer
follow_count
)
{
this
.
follow_count
=
follow_count
;
public
String
getImgUrl
()
{
return
imgUrl
;
}
}
public
String
getVerify_content
()
{
return
verify_content
;
public
Date
getCreateTime
()
{
return
createTime
;
}
}
public
void
setVerify_content
(
String
verify_content
)
{
this
.
verify_content
=
verify_content
;
public
String
getGender
()
{
return
gender
;
}
}
public
String
getImg_url
()
{
public
Integer
getUserType
()
{
return
img_url
;
return
userType
;
}
}
public
void
setImg_url
(
String
img_url
)
{
public
Integer
getAuthType
(
)
{
this
.
img_url
=
img_url
;
return
authType
;
}
}
public
Date
getCreate_time
(
)
{
public
void
setId
(
String
id
)
{
return
create_time
;
this
.
id
=
id
;
}
}
public
void
set
Create_time
(
Date
create_time
)
{
public
void
set
UserId
(
Long
userId
)
{
this
.
create_time
=
create_time
;
this
.
userId
=
userId
;
}
}
public
String
getGender
()
{
public
void
setName
(
String
name
)
{
return
gender
;
this
.
name
=
name
;
}
public
void
setMediaId
(
Long
mediaId
)
{
this
.
mediaId
=
mediaId
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
void
setUserVerified
(
Integer
userVerified
)
{
this
.
userVerified
=
userVerified
;
}
public
void
setVerifyContent
(
String
verifyContent
)
{
this
.
verifyContent
=
verifyContent
;
}
public
void
setFollowCount
(
Integer
followCount
)
{
this
.
followCount
=
followCount
;
}
public
void
setFriendCount
(
Integer
friendCount
)
{
this
.
friendCount
=
friendCount
;
}
}
public
int
getFriend_count
(
)
{
public
void
setImgUrl
(
String
imgUrl
)
{
return
friend_count
;
this
.
imgUrl
=
imgUrl
;
}
}
public
void
set
Friend_count
(
int
friend_count
)
{
public
void
set
CreateTime
(
Date
createTime
)
{
this
.
friend_count
=
friend_count
;
this
.
createTime
=
createTime
;
}
}
...
@@ -185,18 +218,23 @@ public class TouTiaoAccount implements Serializable{
...
@@ -185,18 +218,23 @@ public class TouTiaoAccount implements Serializable{
}
}
public
String
getUser_type
(
)
{
public
void
setUserType
(
Integer
userType
)
{
return
user_t
ype
;
this
.
userType
=
userT
ype
;
}
}
public
void
setUser_type
(
String
user_type
)
{
public
void
setAuthType
(
Integer
authType
)
{
this
.
user_type
=
user_type
;
this
.
authType
=
authType
;
}
public
Boolean
getIsDv
()
{
return
isDv
;
}
public
void
setIsDv
(
Boolean
isDv
)
{
this
.
isDv
=
isDv
;
}
}
}
}
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
View file @
d7da84ad
...
@@ -2,6 +2,7 @@ package com.zhiwei.toutiao.parse;
...
@@ -2,6 +2,7 @@ package com.zhiwei.toutiao.parse;
import
java.net.Proxy
;
import
java.net.Proxy
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -9,6 +10,7 @@ import java.util.Objects;
...
@@ -9,6 +10,7 @@ import java.util.Objects;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.util.Strings
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -47,7 +49,7 @@ public class TouTiaoAccountParse {
...
@@ -47,7 +49,7 @@ public class TouTiaoAccountParse {
public
static
TouTiaoAccount
getTouTiaoAccountInfoByName
(
String
name
,
Proxy
proxy
){
public
static
TouTiaoAccount
getTouTiaoAccountInfoByName
(
String
name
,
Proxy
proxy
){
String
url
=
"https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search&offset=0&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&autoload=true&count=20&en_qc=1&cur_tab=4&from=media&pd=user×tamp="
+
System
.
currentTimeMillis
();
String
url
=
"https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search&offset=0&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&autoload=true&count=20&en_qc=1&cur_tab=4&from=media&pd=user×tamp="
+
System
.
currentTimeMillis
();
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
.
put
(
"cookie"
,
"s_v_web_id=
58999cab9d5be664e02f961e52e59269"
);
headerMap
.
put
(
"cookie"
,
"s_v_web_id=
"
+
Signature
.
parseStrToMd5L32
(
name
)
);
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
try
{
try
{
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
...
@@ -63,28 +65,26 @@ public class TouTiaoAccountParse {
...
@@ -63,28 +65,26 @@ public class TouTiaoAccountParse {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
fillInStackTrace
();
e
.
fillInStackTrace
();
logger
.
error
(
"获取今日头条帐号数据连接超时 {}"
,
e
);
logger
.
error
(
"获取今日头条帐号数据连接超时 {}"
,
e
);
return
null
;
}
}
return
tta
;
return
tta
;
}
}
public
static
TouTiaoAccount
getTouTiaoAccountInfoByUserId
(
String
user
_i
d
,
Proxy
proxy
){
public
static
TouTiaoAccount
getTouTiaoAccountInfoByUserId
(
String
user
I
d
,
Proxy
proxy
){
String
url
=
"https://www.toutiao.com/c/user/"
+
user_id
+
"/"
;
String
url
=
"https://www.toutiao.com/c/user/"
+
userId
+
"/"
;
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
.
put
(
"cookie"
,
"s_v_web_id=
58999cab9d5be664e02f961e52e59269"
);
headerMap
.
put
(
"cookie"
,
"s_v_web_id=
"
+
Signature
.
parseStrToMd5L32
(
userId
)
);
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
try
{
try
{
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
if
(
htmlBody
!=
null
){
if
(
htmlBody
!=
null
){
tta
=
parseAccountByUserId
(
htmlBody
,
user
_i
d
,
proxy
);
tta
=
parseAccountByUserId
(
htmlBody
,
user
I
d
,
proxy
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
fillInStackTrace
();
e
.
fillInStackTrace
();
logger
.
error
(
"获取今日头条帐号数据连接超时"
,
e
);
logger
.
error
(
"获取今日头条帐号数据连接超时"
,
e
);
return
null
;
}
}
return
tta
;
return
tta
;
}
}
...
@@ -108,7 +108,6 @@ public class TouTiaoAccountParse {
...
@@ -108,7 +108,6 @@ public class TouTiaoAccountParse {
while
(
f
){
while
(
f
){
String
url
=
"https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search&offset="
+
page
*
20
+
"&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
word
,
"utf-8"
)+
"&autoload=true&count=20&en_qc=1&cur_tab=4&from=media&pd=user"
;
String
url
=
"https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search&offset="
+
page
*
20
+
"&format=json&keyword="
+
URLCodeUtil
.
getURLEncode
(
word
,
"utf-8"
)+
"&autoload=true&count=20&en_qc=1&cur_tab=4&from=media&pd=user"
;
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
=
Tools
.
getTouTiaoHeader
();
System
.
out
.
println
(
url
);
try
{
try
{
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
if
(
htmlBody
!=
null
){
if
(
htmlBody
!=
null
){
...
@@ -146,7 +145,6 @@ public class TouTiaoAccountParse {
...
@@ -146,7 +145,6 @@ public class TouTiaoAccountParse {
int
page
=
0
;
int
page
=
0
;
while
(
more
){
while
(
more
){
String
url
=
"http://it-hl.snssdk.com/user/relation/following/v2/?user_id="
+
userid
+
"&device_id=54560738994&cursor=&iid=53238029655&offset="
+
page
*
50
+
"&count=50&ts="
+
System
.
currentTimeMillis
()/
1000
;
String
url
=
"http://it-hl.snssdk.com/user/relation/following/v2/?user_id="
+
userid
+
"&device_id=54560738994&cursor=&iid=53238029655&offset="
+
page
*
50
+
"&count=50&ts="
+
System
.
currentTimeMillis
()/
1000
;
System
.
out
.
println
(
url
);
page
++;
page
++;
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
.
put
(
"User-Agent"
,
"Dalvik/2.1.0 (Linux; U; Android 8.1.0; MI 8 MIUI/V10.0.11.0.OEACNFH) NewsArticle/7.0.1 cronet/TTNetVersion:pre_blink_merge-277498-gd2bb364e 2018-08-24"
);
headerMap
.
put
(
"User-Agent"
,
"Dalvik/2.1.0 (Linux; U; Android 8.1.0; MI 8 MIUI/V10.0.11.0.OEACNFH) NewsArticle/7.0.1 cronet/TTNetVersion:pre_blink_merge-277498-gd2bb364e 2018-08-24"
);
...
@@ -169,7 +167,6 @@ public class TouTiaoAccountParse {
...
@@ -169,7 +167,6 @@ public class TouTiaoAccountParse {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取今日头条帐号数据连接超时"
,
e
.
fillInStackTrace
());
logger
.
error
(
"获取今日头条帐号数据连接超时"
,
e
.
fillInStackTrace
());
more
=
false
;
more
=
false
;
return
null
;
}
}
}
}
return
ttaList
;
return
ttaList
;
...
@@ -179,11 +176,10 @@ public class TouTiaoAccountParse {
...
@@ -179,11 +176,10 @@ public class TouTiaoAccountParse {
public
static
List
<
TouTiaoAccount
>
getFriendsList
(
String
userid
,
ProxyHolder
proxy
){
public
static
List
<
TouTiaoAccount
>
getFriendsList
(
String
userid
,
ProxyHolder
proxy
){
List
<
TouTiaoAccount
>
ttaList
=
new
ArrayList
<>();
List
<
TouTiaoAccount
>
ttaList
=
new
ArrayList
<>();
Signature
signature
=
new
Signature
(
userid
,
"0"
);
Signature
signature
=
new
Signature
(
userid
,
"0"
);
String
_signature
=
signature
.
getSignature
();
String
signatureStr
=
signature
.
getSignature
();
boolean
more
=
true
;
boolean
more
=
true
;
while
(
more
){
while
(
more
){
String
url
=
"https://www.toutiao.com/c/user/following/?user_id="
+
userid
+
"&cursor=0&count=100&_signature="
+
_signature
;
String
url
=
"https://www.toutiao.com/c/user/following/?user_id="
+
userid
+
"&cursor=0&count=100&_signature="
+
signatureStr
;
System
.
out
.
println
(
url
);
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
.
put
(
"referer"
,
"ihttps://www.toutiao.com/c/user/relation/"
+
userid
+
"/?tab=following"
);
headerMap
.
put
(
"referer"
,
"ihttps://www.toutiao.com/c/user/relation/"
+
userid
+
"/?tab=following"
);
headerMap
.
put
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36"
);
headerMap
.
put
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36"
);
...
@@ -202,12 +198,10 @@ public class TouTiaoAccountParse {
...
@@ -202,12 +198,10 @@ public class TouTiaoAccountParse {
}
}
}
else
{
}
else
{
more
=
false
;
more
=
false
;
continue
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取今日头条帐号数据连接超时"
,
e
.
fillInStackTrace
());
logger
.
error
(
"获取今日头条帐号数据连接超时"
,
e
.
fillInStackTrace
());
more
=
false
;
more
=
false
;
continue
;
}
}
}
}
}
}
...
@@ -230,58 +224,63 @@ public class TouTiaoAccountParse {
...
@@ -230,58 +224,63 @@ public class TouTiaoAccountParse {
}
}
JSONObject
json
=
JSONObject
.
parseObject
(
htmlBody
);
JSONObject
json
=
JSONObject
.
parseObject
(
htmlBody
);
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
Long
user
_i
d
=
null
;
Long
user
I
d
=
null
;
String
name
=
null
;
String
name
=
null
;
Long
media
_id
=
-
1L
;
Long
media
Id
=
null
;
String
description
=
null
;
String
description
=
null
;
Integer
user
_verified
=
-
1
;
Integer
user
Verified
=
0
;
String
verify
_c
ontent
=
null
;
String
verify
C
ontent
=
null
;
Integer
follow
_count
=
-
1
;
Integer
follow
Count
=
null
;
Date
create
_t
ime
=
null
;
Date
create
T
ime
=
null
;
String
img
_u
rl
=
null
;
String
img
U
rl
=
null
;
String
gender
=
null
;
String
gender
=
null
;
String
user_type
=
null
;
Integer
userType
=
null
;
Integer
authType
=
null
;
Boolean
isDv
=
null
;
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
try
{
try
{
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
if
(
data
.
getLong
(
"id"
)
==
null
)
{
if
(
data
.
getLong
(
"
media_
id"
)
==
null
)
{
continue
;
continue
;
}
}
user_id
=
data
.
getLong
(
"id"
);
name
=
data
.
getString
(
"name"
);
name
=
data
.
getString
(
"name"
);
if
(
data
.
getLong
(
"media_id"
)
!=
null
)
{
media_id
=
data
.
getLong
(
"media_id"
);
}
description
=
data
.
getString
(
"description"
);
if
(
data
.
getInteger
(
"user_verified"
)
!=
null
)
{
user_verified
=
data
.
getInteger
(
"user_verified"
);
}
verify_content
=
data
.
getString
(
"verify_content"
);
if
(
data
.
getInteger
(
"follow_count"
)
!=
null
)
{
follow_count
=
data
.
getInteger
(
"follow_count"
);
}
img_url
=
"https:"
+
data
.
getString
(
"avatar_url"
);
if
(
data
.
getString
(
"create_time"
)
!=
null
)
{
create_time
=
new
Date
(
Long
.
valueOf
(
data
.
getString
(
"create_time"
))*
1000
);
}
gender
=
data
.
getString
(
"gender"
);
user_type
=
data
.
getString
(
"user_type"
);
if
(
name
!=
null
&&
name
.
equals
(
word
)){
if
(
name
!=
null
&&
name
.
equals
(
word
)){
tta
=
new
TouTiaoAccount
(
user_id
,
name
,
media_id
,
description
,
user_verified
,
userId
=
data
.
getLong
(
"id"
);
verify_content
,
follow_count
,
img_url
,
create_time
,
gender
,
user_type
);
if
(
data
.
getLong
(
"media_id"
)
!=
null
)
{
mediaId
=
data
.
getLong
(
"media_id"
);
}
description
=
data
.
getString
(
"description"
);
verifyContent
=
data
.
getString
(
"verify_content"
);
if
(
data
.
getJSONObject
(
"user_auth_info"
)
!=
null
&&
!
data
.
getJSONObject
(
"user_auth_info"
).
isEmpty
())
{
userVerified
=
1
;
verifyContent
=
data
.
getJSONObject
(
"user_auth_info"
).
getString
(
"auth_info"
);
authType
=
data
.
getJSONObject
(
"user_auth_info"
).
getInteger
(
"auth_type"
);
}
if
(
data
.
getInteger
(
"follow_count"
)
!=
null
)
{
followCount
=
data
.
getInteger
(
"follow_count"
);
}
imgUrl
=
"https:"
+
data
.
getString
(
"avatar_url"
);
if
(
data
.
getString
(
"create_time"
)
!=
null
)
{
createTime
=
new
Date
(
Long
.
valueOf
(
data
.
getString
(
"create_time"
))*
1000
);
}
gender
=
data
.
getString
(
"gender"
);
userType
=
data
.
getInteger
(
"user_type"
);
tta
=
new
TouTiaoAccount
(
userId
,
name
,
mediaId
,
description
,
userVerified
,
verifyContent
,
followCount
,
imgUrl
,
createTime
,
gender
,
userType
,
authType
,
isDv
);
ZhiWeiTools
.
sleep
(
1000
);
ZhiWeiTools
.
sleep
(
1000
);
TouTiaoAccount
ttaUpdate
=
getTouTiaoAccountInfoByUserId
(
user
_i
d
+
""
,
proxy
);
TouTiaoAccount
ttaUpdate
=
getTouTiaoAccountInfoByUserId
(
user
I
d
+
""
,
proxy
);
if
(
ttaUpdate
!=
null
){
if
(
ttaUpdate
!=
null
){
tta
.
setFriend_count
(
ttaUpdate
.
getFriend_count
());
tta
.
setFriendCount
(
ttaUpdate
.
getFriendCount
());
tta
.
setUser_type
(
ttaUpdate
.
getUser_type
());
tta
.
setUserType
(
ttaUpdate
.
getUserType
());
tta
.
setIsDv
(
ttaUpdate
.
getIsDv
());
}
}
return
tta
;
return
tta
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
continue
;
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -307,18 +306,25 @@ public class TouTiaoAccountParse {
...
@@ -307,18 +306,25 @@ public class TouTiaoAccountParse {
if
(
htmlBody
.
contains
(
"var header={"
)){
if
(
htmlBody
.
contains
(
"var header={"
)){
String
name
=
htmlBody
.
split
(
"var header"
)[
1
].
split
(
"name:'"
)[
1
].
split
(
"',"
)[
0
];
String
name
=
htmlBody
.
split
(
"var header"
)[
1
].
split
(
"name:'"
)[
1
].
split
(
"',"
)[
0
];
String
imgUrl
=
"https:"
+
htmlBody
.
split
(
"avtar_img:'"
)[
1
].
split
(
"',"
)[
0
];
String
imgUrl
=
"https:"
+
htmlBody
.
split
(
"avtar_img:'"
)[
1
].
split
(
"',"
)[
0
];
String
type
=
htmlBody
.
split
(
"type: '"
)[
1
].
split
(
"'"
)[
0
];
Integer
type
=
Integer
.
valueOf
(
htmlBody
.
split
(
"type: '"
)[
1
].
split
(
"'"
)[
0
]);
String
isDvStr
=
htmlBody
.
split
(
"dv:"
)[
1
].
split
(
","
)[
0
];
Boolean
isDv
=
false
;
if
(
"true"
.
equals
(
isDvStr
)){
isDv
=
true
;
}
if
(
htmlBody
.
contains
(
"guanzhu"
)){
if
(
htmlBody
.
contains
(
"guanzhu"
)){
int
guanzhu
=
Integer
.
valueOf
(
htmlBody
.
split
(
"guanzhu:'"
)[
1
].
split
(
"',"
)[
0
]);
int
guanzhu
=
Integer
.
valueOf
(
htmlBody
.
split
(
"guanzhu:'"
)[
1
].
split
(
"',"
)[
0
]);
int
fensi
=
Integer
.
valueOf
(
htmlBody
.
split
(
"fensi:'"
)[
1
].
split
(
"',"
)[
0
]);
int
fensi
=
Integer
.
valueOf
(
htmlBody
.
split
(
"fensi:'"
)[
1
].
split
(
"',"
)[
0
]);
touTiaoAccount
.
setFriend
_c
ount
(
guanzhu
);
touTiaoAccount
.
setFriend
C
ount
(
guanzhu
);
touTiaoAccount
.
setFollow
_c
ount
(
fensi
);
touTiaoAccount
.
setFollow
C
ount
(
fensi
);
}
}
touTiaoAccount
.
setId
(
userId
);
touTiaoAccount
.
setId
(
userId
);
touTiaoAccount
.
setUser
_i
d
(
Long
.
valueOf
(
userId
));
touTiaoAccount
.
setUser
I
d
(
Long
.
valueOf
(
userId
));
touTiaoAccount
.
setImg
_u
rl
(
imgUrl
);
touTiaoAccount
.
setImg
U
rl
(
imgUrl
);
touTiaoAccount
.
setName
(
name
);
touTiaoAccount
.
setName
(
name
);
touTiaoAccount
.
setUser_type
(
type
);
touTiaoAccount
.
setUserType
(
type
);
touTiaoAccount
.
setIsDv
(
isDv
);
return
touTiaoAccount
;
return
touTiaoAccount
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -345,54 +351,60 @@ public class TouTiaoAccountParse {
...
@@ -345,54 +351,60 @@ public class TouTiaoAccountParse {
List
<
TouTiaoAccount
>
ttaList
=
new
ArrayList
<>();
List
<
TouTiaoAccount
>
ttaList
=
new
ArrayList
<>();
try
{
try
{
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
long
user_id
=
0
;
Long
userId
=
null
;
String
name
=
null
;
String
name
=
null
;
long
media_id
=
0
;
Long
mediaId
=
null
;
String
description
=
null
;
String
description
=
null
;
int
user_v
erified
=
0
;
Integer
userV
erified
=
0
;
String
verify
_c
ontent
=
null
;
String
verify
C
ontent
=
null
;
int
follow_count
=
0
;
Integer
followCount
=
null
;
String
img_url
=
null
;
Date
createTime
=
null
;
Date
create_time
=
null
;
String
imgUrl
=
null
;
String
gender
=
null
;
String
gender
=
null
;
String
user_type
=
null
;
Integer
userType
=
null
;
Integer
authType
=
null
;
Boolean
isDv
=
null
;
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
try
{
try
{
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
user
_i
d
=
data
.
getLong
(
"id"
);
user
I
d
=
data
.
getLong
(
"id"
);
name
=
data
.
getString
(
"name"
);
name
=
data
.
getString
(
"name"
);
if
(
data
.
containsKey
(
"media_id"
))
{
if
(
data
.
containsKey
(
"media_id"
))
{
media
_i
d
=
data
.
getLong
(
"media_id"
);
media
I
d
=
data
.
getLong
(
"media_id"
);
}
}
description
=
data
.
getString
(
"description"
);
description
=
data
.
getString
(
"description"
);
user_verified
=
data
.
getInteger
(
"user_verified"
);
verifyContent
=
data
.
getString
(
"verify_content"
);
verify_content
=
data
.
getString
(
"verify_content"
);
if
(
data
.
getJSONObject
(
"user_auth_info"
)
!=
null
&&
!
data
.
getJSONObject
(
"user_auth_info"
).
isEmpty
())
{
follow_count
=
data
.
getInteger
(
"follow_count"
);
userVerified
=
1
;
img_url
=
"https:"
+
data
.
getString
(
"avatar_url"
);
verifyContent
=
data
.
getJSONObject
(
"user_auth_info"
).
getString
(
"auth_info"
);
create_time
=
new
Date
(
Long
.
parseLong
((
data
.
getString
(
"create_time"
)+
"000"
)));
authType
=
data
.
getJSONObject
(
"user_auth_info"
).
getInteger
(
"auth_type"
);
}
followCount
=
data
.
getInteger
(
"follow_count"
);
imgUrl
=
"https:"
+
data
.
getString
(
"avatar_url"
);
createTime
=
new
Date
(
Long
.
parseLong
((
data
.
getString
(
"create_time"
)+
"000"
)));
gender
=
data
.
getString
(
"gender"
);
gender
=
data
.
getString
(
"gender"
);
user
_type
=
data
.
getString
(
"user_type"
);
user
Type
=
data
.
getInteger
(
"user_type"
);
tta
=
new
TouTiaoAccount
(
user
_id
,
name
,
media_id
,
description
,
user_v
erified
,
tta
=
new
TouTiaoAccount
(
user
Id
,
name
,
mediaId
,
description
,
userV
erified
,
verify
_content
,
follow_count
,
img_url
,
create_time
,
gender
,
user_type
);
verify
Content
,
followCount
,
imgUrl
,
createTime
,
gender
,
userType
,
authType
,
isDv
);
if
(
Objects
.
nonNull
(
proxy
))
{
if
(
Objects
.
nonNull
(
proxy
))
{
ZhiWeiTools
.
sleep
(
1000
);
ZhiWeiTools
.
sleep
(
1000
);
}
}
TouTiaoAccount
ttaUpdate
=
getTouTiaoAccountInfoByUserId
(
user
_i
d
+
""
,
proxy
);
TouTiaoAccount
ttaUpdate
=
getTouTiaoAccountInfoByUserId
(
user
I
d
+
""
,
proxy
);
if
(
ttaUpdate
!=
null
){
if
(
ttaUpdate
!=
null
){
tta
.
setFriend_count
(
ttaUpdate
.
getFriend_count
());
tta
.
setFriendCount
(
ttaUpdate
.
getFriendCount
());
tta
.
setUser_type
(
ttaUpdate
.
getUser_type
());
tta
.
setUserType
(
ttaUpdate
.
getUserType
());
tta
.
setIsDv
(
ttaUpdate
.
getIsDv
());
}
}
ttaList
.
add
(
tta
);
ttaList
.
add
(
tta
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
continue
;
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
return
null
;
return
Collections
.
emptyList
()
;
}
}
return
ttaList
;
return
ttaList
;
}
}
...
@@ -411,39 +423,40 @@ public class TouTiaoAccountParse {
...
@@ -411,39 +423,40 @@ public class TouTiaoAccountParse {
try
{
try
{
ttaList
=
new
ArrayList
<>();
ttaList
=
new
ArrayList
<>();
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
JSONArray
jsonArray
=
json
.
getJSONArray
(
"data"
);
Long
user
_i
d
=
null
;
Long
user
I
d
=
null
;
String
name
=
null
;
String
name
=
null
;
Long
media
_i
d
=
null
;
Long
media
I
d
=
null
;
String
description
=
null
;
String
description
=
null
;
Integer
user
_v
erified
=
null
;
Integer
user
V
erified
=
null
;
String
verify
_c
ontent
=
null
;
String
verify
C
ontent
=
null
;
int
follow_count
=
0
;
Integer
followCount
=
null
;
String
img_url
=
null
;
Date
createTime
=
null
;
Date
create_time
=
null
;
String
imgUrl
=
null
;
String
gender
=
null
;
String
gender
=
null
;
String
user_type
=
null
;
Integer
userType
=
null
;
Integer
authType
=
null
;
Boolean
isDv
=
null
;
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
try
{
try
{
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
user
_i
d
=
data
.
getLong
(
"user_id"
);
user
I
d
=
data
.
getLong
(
"user_id"
);
media
_i
d
=
data
.
getLong
(
"media_id"
);
media
I
d
=
data
.
getLong
(
"media_id"
);
name
=
data
.
getString
(
"name"
);
name
=
data
.
getString
(
"name"
);
img
_u
rl
=
"https:"
+
data
.
getString
(
"avatar_url"
);
img
U
rl
=
"https:"
+
data
.
getString
(
"avatar_url"
);
user
_v
erified
=
data
.
getInteger
(
"user_verified"
);
user
V
erified
=
data
.
getInteger
(
"user_verified"
);
verify
_c
ontent
=
data
.
getString
(
"verified_content"
);
verify
C
ontent
=
data
.
getString
(
"verified_content"
);
tta
=
new
TouTiaoAccount
(
user
_id
,
name
,
media_id
,
description
,
user_v
erified
,
tta
=
new
TouTiaoAccount
(
user
Id
,
name
,
mediaId
,
description
,
userV
erified
,
verify
_content
,
follow_count
,
img_url
,
create_time
,
gender
,
user_type
);
verify
Content
,
followCount
,
imgUrl
,
createTime
,
gender
,
userType
,
authType
,
isDv
);
ttaList
.
add
(
tta
);
ttaList
.
add
(
tta
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
continue
;
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
return
null
;
return
Collections
.
emptyList
()
;
}
}
return
ttaList
;
return
ttaList
;
}
}
...
@@ -465,37 +478,38 @@ public class TouTiaoAccountParse {
...
@@ -465,37 +478,38 @@ public class TouTiaoAccountParse {
try
{
try
{
ttaList
=
new
ArrayList
<>();
ttaList
=
new
ArrayList
<>();
JSONArray
jsonArray
=
json
.
getJSONObject
(
"data"
).
getJSONArray
(
"users"
);
JSONArray
jsonArray
=
json
.
getJSONObject
(
"data"
).
getJSONArray
(
"users"
);
Long
user
_i
d
=
null
;
Long
user
I
d
=
null
;
String
name
=
null
;
String
name
=
null
;
String
description
=
null
;
String
description
=
null
;
Integer
user
_verified
=
null
;
Integer
user
Verified
=
-
1
;
String
verify
_c
ontent
=
null
;
String
verify
C
ontent
=
null
;
int
follow_count
=
0
;
Integer
followCount
=
-
1
;
String
img_url
=
null
;
Date
createTime
=
null
;
Date
create_time
=
null
;
String
imgUrl
=
null
;
String
gender
=
null
;
String
gender
=
null
;
String
user_type
=
null
;
Integer
userType
=
null
;
Integer
authType
=
null
;
Boolean
isDv
=
null
;
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
try
{
try
{
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
data
=
jsonArray
.
getJSONObject
(
i
);
user
_i
d
=
data
.
getLong
(
"user_id"
);
user
I
d
=
data
.
getLong
(
"user_id"
);
name
=
data
.
getString
(
"name"
);
name
=
data
.
getString
(
"name"
);
description
=
data
.
getString
(
"description"
);
description
=
data
.
getString
(
"description"
);
verify
_c
ontent
=
data
.
getString
(
"verified_content"
);
verify
C
ontent
=
data
.
getString
(
"verified_content"
);
img
_u
rl
=
data
.
getString
(
"avatar_url"
);
img
U
rl
=
data
.
getString
(
"avatar_url"
);
user
_verified
=
data
.
getBoolean
(
"user_verified"
)==
true
?
0
:
1
;
user
Verified
=
data
.
getBoolean
(
"user_verified"
)
==
true
?
0
:
1
;
tta
=
new
TouTiaoAccount
(
user
_id
,
name
,
null
,
description
,
user_v
erified
,
tta
=
new
TouTiaoAccount
(
user
Id
,
name
,
null
,
description
,
userV
erified
,
verify
_content
,
follow_count
,
img_url
,
create_time
,
gender
,
user_type
);
verify
Content
,
followCount
,
imgUrl
,
createTime
,
gender
,
userType
,
authType
,
isDv
);
ttaList
.
add
(
tta
);
ttaList
.
add
(
tta
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
continue
;
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
logger
.
error
(
"数据解析出现问题,{}"
,
e
);
return
null
;
return
Collections
.
emptyList
()
;
}
}
return
ttaList
;
return
ttaList
;
}
}
...
@@ -516,12 +530,10 @@ public class TouTiaoAccountParse {
...
@@ -516,12 +530,10 @@ public class TouTiaoAccountParse {
logger
.
error
(
"获取数据时出现问题,问题为:{}"
,
e
.
fillInStackTrace
());
logger
.
error
(
"获取数据时出现问题,问题为:{}"
,
e
.
fillInStackTrace
());
if
(
i
==
3
){
if
(
i
==
3
){
break
;
break
;
}
else
{
continue
;
}
}
}
}
}
}
return
null
;
return
Strings
.
EMPTY
;
}
}
}
}
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