Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
马玮
/
carspider
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5428dec9
authored
Aug 16, 2017
by
马玮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add getHeaderCookie
parent
2a7e029e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
README.md
+1
-1
lib/helpers/Dealer.js
+15
-0
lib/spider/dealer/AutoHome.js
+2
-10
No files found.
README.md
View file @
5428dec9
...
@@ -43,5 +43,5 @@ sudo yum install redis
...
@@ -43,5 +43,5 @@ sudo yum install redis
-
[
]
优化:进程Graceful Stop
-
[
]
优化:进程Graceful Stop
-
[
]
优化:统一所有代码let和const的使用风格
-
[
]
优化:统一所有代码let和const的使用风格
-
[
x
]
重构:使用ES7语法重构代码
-
[
x
]
重构:使用ES7语法重构代码
-
[
]
重构:创建Spider基类复用代码(setCookies|getCookies|getHeaderCookies
)
-
[
x
]
重构:创建Spider基类复用代码(setCookies|getCookies|getHeaderCookie
)
-
[
]
重构:使用import|export写法增加模块读取速度
-
[
]
重构:使用import|export写法增加模块读取速度
lib/helpers/Dealer.js
View file @
5428dec9
...
@@ -19,6 +19,21 @@ class DealerHelper {
...
@@ -19,6 +19,21 @@ class DealerHelper {
}
}
}
}
static
async
getHeaderCookie
(
params
)
{
try
{
const
cookies
=
await
DealerHelper
.
getCookies
(
params
);
const
cookieStrs
=
[];
cookies
.
forEach
((
cookie
)
=>
{
cookieStrs
.
push
(
`
${
cookie
.
name
}
=
${
cookie
.
value
}
`
);
});
return
cookieStrs
.
join
(
';'
);
}
catch
(
e
)
{
return
null
;
}
}
static
async
saveCookies
(
params
)
{
static
async
saveCookies
(
params
)
{
try
{
try
{
// 延长过期时间为一个月后
// 延长过期时间为一个月后
...
...
lib/spider/dealer/AutoHome.js
View file @
5428dec9
...
@@ -187,15 +187,7 @@ class AutoHome {
...
@@ -187,15 +187,7 @@ class AutoHome {
return
;
return
;
}
}
const
cookies
=
await
DealerHelper
.
getCookies
(
this
.
params
);
const
headerCookie
=
await
DealerHelper
.
getHeaderCookie
(
this
.
params
);
// console.log(JSON.stringify(cookies));return;
const
cookieArray
=
[];
cookies
.
forEach
((
cookie
)
=>
{
cookieArray
.
push
(
`
${
cookie
.
name
}
=
${
cookie
.
value
}
`
);
});
const
cookieStr
=
cookieArray
.
join
(
';'
);
let
rowcount
;
let
rowcount
;
let
customerIndex
=
0
;
let
customerIndex
=
0
;
...
@@ -227,7 +219,7 @@ class AutoHome {
...
@@ -227,7 +219,7 @@ class AutoHome {
axios
.
get
(
'http://ics.autohome.com.cn/Dms/Order/SearchOrderList'
,
{
axios
.
get
(
'http://ics.autohome.com.cn/Dms/Order/SearchOrderList'
,
{
params
:
params
,
params
:
params
,
headers
:{
headers
:{
Cookie
:
cookieStr
Cookie
:
headerCookie
}
}
}).
then
(
async
res
=>
{
}).
then
(
async
res
=>
{
const
clueData
=
res
.
data
;
const
clueData
=
res
.
data
;
...
...
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