Commit fe17e966 by 马玮

change code style

parent 63289abf
......@@ -2,7 +2,6 @@
User: MaWei
Date: 2017.7.31
*/
const path = require('path');
const program = require('commander');
const config = require('config');
......
......@@ -5,29 +5,29 @@ host = "http://api.dama2.com:7766/app/"
user = "test"
pwd = "test"
[dealer_account.ifeng]
[Dealer.ifeng]
username = "上海车城汽车"
password = "Checheng235#"
captcha_type = "4_letter_number"
captchaType = "FOUR_CHARACTERS"
[dealer_account.easypass]
[Dealer.easypass]
username = "100074110"
password = "hnmz147852"
captcha_type = "calculation"
captchaType = "ARITHMETIC"
[dealer_account.autohome]
[Dealer.autohome]
username = "河南明志汽车大迈8054"
password = "hnmz147852"
captcha_type = "4_letter"
captchaType = "FOUR_LETTERS"
[captcha.ruokuai]
[Captcha.ruokuai]
username = "chedev"
password = "Checheng235#"
softid = 86134
softkey = "b167ed636a224990a2f04ae2d28d1542"
[captcha.ruokuai.typeids]
4_letter = 2040
4_letter_number = 3040
calculation = 7100
[Captcha.ruokuai.typeids]
FOUR_LETTERS = 2040 # 四个英文字母
FOUR_CHARACTERS = 3040 # 四个字母数字混合
ARITHMETIC = 7100 # 算术题
......@@ -2,11 +2,11 @@ const config = require('config');
const ruokuai = require('./ruokuai');
const captcha = exports;
captcha.decode = function (captcha_type, imagefile, callback) {
console.log(captcha_type);
console.log(imagefile);
const typeids = config.get('captcha.ruokuai.typeids');
typeid = typeids[captcha_type];
ruokuai.decode(typeid, imagefile, function (captcha) {
captcha.decode = function (captchaType, imageFile, callback) {
console.log(captchaType);
console.log(imageFile);
const typeids = config.get('Captcha.ruokuai.typeids');
typeid = typeids[captchaType];
ruokuai.decode(typeid, imageFile, function (captcha) {
});
}
\ No newline at end of file
......@@ -7,16 +7,16 @@ const request = require('request');
const filename = '2.png';
let ruokuai = exports;
ruokuai.decode = function (typeid, imagefile, callback) {
let ruokuai_info = config.get('captcha.ruokuai');
const image = fs.createReadStream(imagefile);
ruokuai.decode = function (typeid, imageFile, callback) {
let ruokuaiInfo = config.get('Captcha.ruokuai');
const image = fs.createReadStream(imageFile);
formData = {
username: ruokuai_info.username,
password: ruokuai_info.password,
softid: ruokuai_info.softid,
softkey: ruokuai_info.softkey,
username: ruokuaiInfo.username,
password: ruokuaiInfo.password,
softid: ruokuaiInfo.softid,
softkey: ruokuaiInfo.softkey,
typeid: typeid,
image: fs.createReadStream(imagefile)
image: fs.createReadStream(imageFile)
}
request.post({url:'http://api.ruokuai.com/create.json', formData: formData}, function optionalCallback(err, httpResponse, body) {
if (err) {
......
......@@ -2,9 +2,11 @@
User: MaWei
Date: 2017.7.31
*/
process.env.NODE_CONFIG_DIR = '../config';
const program = require('commander');
const config = require('config');
const captcha = require('./lib/captcha');
const captcha = require('../lib/captcha');
program
.version('1.0.0')
......@@ -12,8 +14,7 @@ program
.parse(process.argv);
(function() {
console.log(config);
captcha_type = config.get('dealer_account')[program.website]['captcha_type'];
const imagefile = 'test/images/' + program.website + '.png';
captcha_type = config.get('Dealer')[program.website]['captchaType'];
const imagefile = 'images/' + program.website + '.png';
captcha.decode(captcha_type, imagefile);
}());
\ No newline at end of file
/*
User: MaWei
Date: 2017.7.31
*/
const program = require('commander');
const config = require('config');
const captcha = require('./lib/captcha');
program
.version('1.0.0')
.option('-w, --website <website name>', 'Add website we want fetch')
.parse(process.argv);
(function() {
console.log(config);
captcha_type = config.get('dealer_account')[program.website]['captcha_type'];
const imagefile = 'test/images/' + program.website + '.png';
captcha.decode(captcha_type, imagefile);
}());
\ No newline at end of file
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