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
9db65425
Commit
9db65425
authored
Apr 29, 2019
by
yangchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加默认 cookie 需观察何时失效
parent
3a3a77d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletions
+6
-1
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
+3
-0
src/main/java/com/zhiwei/toutiao/parse/TouTiaoSearchParse.java
+3
-1
No files found.
src/main/java/com/zhiwei/toutiao/parse/TouTiaoAccountParse.java
View file @
9db65425
...
@@ -47,6 +47,7 @@ public class TouTiaoAccountParse {
...
@@ -47,6 +47,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"
);
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
try
{
try
{
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
...
@@ -72,6 +73,8 @@ public class TouTiaoAccountParse {
...
@@ -72,6 +73,8 @@ public class TouTiaoAccountParse {
public
static
TouTiaoAccount
getTouTiaoAccountInfoByUserId
(
String
user_id
,
Proxy
proxy
){
public
static
TouTiaoAccount
getTouTiaoAccountInfoByUserId
(
String
user_id
,
Proxy
proxy
){
String
url
=
"https://www.toutiao.com/c/user/"
+
user_id
+
"/"
;
String
url
=
"https://www.toutiao.com/c/user/"
+
user_id
+
"/"
;
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
=
Tools
.
getTouTiaoHeader
();
headerMap
.
put
(
"cookie"
,
"s_v_web_id=58999cab9d5be664e02f961e52e59269"
);
TouTiaoAccount
tta
=
null
;
TouTiaoAccount
tta
=
null
;
try
{
try
{
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
String
htmlBody
=
downloadHtml
(
url
,
proxy
,
headerMap
);
...
...
src/main/java/com/zhiwei/toutiao/parse/TouTiaoSearchParse.java
View file @
9db65425
...
@@ -46,7 +46,9 @@ public class TouTiaoSearchParse {
...
@@ -46,7 +46,9 @@ public class TouTiaoSearchParse {
public
static
Map
<
String
,
Object
>
touTiaoSearchByWord
(
String
url
,
Proxy
proxy
)
throws
Exception
{
public
static
Map
<
String
,
Object
>
touTiaoSearchByWord
(
String
url
,
Proxy
proxy
)
throws
Exception
{
String
htmlBody
=
null
;
String
htmlBody
=
null
;
try
{
try
{
htmlBody
=
downloadHtml
(
url
,
proxy
,
HeaderTool
.
getCommonHead
());
Map
<
String
,
String
>
header
=
HeaderTool
.
getCommonHead
();
header
.
put
(
"cookie"
,
"s_v_web_id=58999cab9d5be664e02f961e52e59269"
);
htmlBody
=
downloadHtml
(
url
,
proxy
,
header
);
if
(
htmlBody
!=
null
){
if
(
htmlBody
!=
null
){
Map
<
String
,
Object
>
dataMap
=
parseHtmlBySearch
(
htmlBody
);
Map
<
String
,
Object
>
dataMap
=
parseHtmlBySearch
(
htmlBody
);
if
(
dataMap
!=
null
&&
dataMap
.
size
()>
0
){
if
(
dataMap
!=
null
&&
dataMap
.
size
()>
0
){
...
...
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