Commit 199080ab by 马玮

autohome ended

parent 53dce1f2
...@@ -37,7 +37,7 @@ class AutoHome { ...@@ -37,7 +37,7 @@ class AutoHome {
await client.quit(); await client.quit();
return cookies; return cookies;
} catch (e) { } catch (e) {
throw e; return null;
} }
} }
...@@ -65,6 +65,7 @@ class AutoHome { ...@@ -65,6 +65,7 @@ class AutoHome {
let loginSuccess = false; let loginSuccess = false;
if (cookies) { if (cookies) {
console.log(JSON.stringify(cookies));
const horseman = new Horseman({ const horseman = new Horseman({
ignoreSSLErrors: true ignoreSSLErrors: true
}); });
...@@ -95,7 +96,7 @@ class AutoHome { ...@@ -95,7 +96,7 @@ class AutoHome {
try { try {
try { try {
await this.tryLogin(); await this.tryLogin();
console.log('登录成功'); console.log('尝试登录成功');
return; return;
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
...@@ -241,7 +242,7 @@ class AutoHome { ...@@ -241,7 +242,7 @@ class AutoHome {
params.assignDealerId = 0; params.assignDealerId = 0;
const fetchByPage = async () => { const fetchByPage = async () => {
if (!rowcount) { if (!rowcount) {
console.log(`线索日期: ${params.startTime} - ${params.startTime}`); console.log(`线索日期: ${params.startTime} - ${params.endtime}`);
} }
console.log(`线索页面: ${params.pageIndex}`); console.log(`线索页面: ${params.pageIndex}`);
axios.get('http://ics.autohome.com.cn/Dms/Order/SearchOrderList?', { axios.get('http://ics.autohome.com.cn/Dms/Order/SearchOrderList?', {
...@@ -259,13 +260,12 @@ class AutoHome { ...@@ -259,13 +260,12 @@ class AutoHome {
for (let clue of clues.result.list) { for (let clue of clues.result.list) {
customerIndex++; customerIndex++;
let $ = cheerio.load(clue.CustomerNameStr); let $ = cheerio.load(clue.CustomerNameStr);
console.log($.html());
let idMatch = $.html().match(/showCusDetailWithId\("(\d*)"\)/); let idMatch = $.html().match(/showCusDetailWithId\("(\d*)"\)/);
clue.CustomerId = idMatch[1] || 0; clue.CustomerId = idMatch[1] || 0;
console.log('客户序号:', customerIndex); console.log('客户序号:', customerIndex);
console.log('客户ID:', clue.CustomerId); console.log('客户ID:', clue.CustomerId);
console.log('客户姓名:', $.text()); console.log('客户姓名:', $.text());
continue;
console.log('客户号码:', clue.CustomerPhoneStr); console.log('客户号码:', clue.CustomerPhoneStr);
console.log('负责销售:', clue.SalesNameStr); console.log('负责销售:', clue.SalesNameStr);
console.log('线索类型:', clue.OrderTypeStr); console.log('线索类型:', clue.OrderTypeStr);
......
'use strict';
/**
* Carspider provides a host of custom error classes, to allow you to do easier debugging.
* All of these errors are exposed on the carspider object and the carspider constructor.
* All carspider errors inherit from the base JS error object.
*
* This means that errors can be accessed using `Carspider.ValidationError` or `Carspider.ValidationError`
* The Base Error all Carspider Errors inherit from.
*/
class AppError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
}
exports.AppError = AppError;
/**
* Thrown when a some problem occurred with Instance methods (see message for details)
*/
class TryLoginError extends AppError {
constructor(message) {
super(message);
this.name = this.constructor.name;
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
}
exports.TryLoginError = TryLoginError;
class LoginError extends AppError {
constructor(options) {
options = options || {};
options.code = options.code || {};
options.message = options.message || '登录失败: ' + options.code;
super(options.message);
this.name = this.constructor.name;
this.message = options.message;
this.code = options.code;
Error.captureStackTrace(this, this.constructor);
}
}
exports.LoginError = LoginError;
class CaptchaDecodeError extends AppError {
constructor(message) {
super(message);
this.name = this.constructor.name;
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
}
exports.CaptchaDecodeError = CaptchaDecodeError;
/**
* Thrown when a some problem occurred with Instance methods (see message for details)
*/
class LoginValidationError extends AppError {
constructor(message) {
super(message);
this.name = this.constructor.name;
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
}
exports.LoginValidationError = LoginValidationError;
\ No newline at end of file
...@@ -3,6 +3,10 @@ const redis = require("redis"); ...@@ -3,6 +3,10 @@ const redis = require("redis");
const client = redis.createClient(); const client = redis.createClient();
const Horseman = require('node-horseman'); const Horseman = require('node-horseman');
Promise.promisifyAll(require("redis")); Promise.promisifyAll(require("redis"));
const moment = require('moment');
const day = moment().subtract(3, 'days').format('YYYY.MM.DD');
console.log(moment().format('YYYY.MM.DD'));
return;
let info = 'showCusDetailWithId("302761")'; let info = 'showCusDetailWithId("302761")';
var m = info.match(/showCusDetailWithId\("(\d*)"\)/); var m = info.match(/showCusDetailWithId\("(\d*)"\)/);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment