Commit fe17e966 by 马玮

change code style

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