node.js - Solve captcha with spookyjs (casperjs) -
i'm trying write test site, logging , performing actions. i've got script close working there 1 key flaw haven't been able circumvent. see logic below
var phantom = require('phantom'); var rl = require('readline-sync'); var spooky = require('spooky'); // go login page spooky.start(url); // generate image of captcha spooky.then(function () { this.capture('captcha.png'); }); // fill in login form spooky.then([{ captcha: new captcha() }, function () { this.fill('form#login-form', { 'username': 'username', 'password': 'password', 'recaptcha_response_field' : captcha.phrase }); }]); spooky.wait(5000, function() { this.capture('afterlogin.png'); }); spooky.run(); function captcha() { return { phrase: ask("enter captcha phrase: ") } } function ask (msg, options){ return rl.question(msg, options) }
so, generates images fine, fills out form fine. problem injecting "new captcha()" function. if, example, didn't need see image of form first, put in username , pass ask function, , fill out. seems evaluate before spooky promises.
when run script, asks phrase first, after enter it generates image. need generate image before asking phrase. if shed light on issue great! let me know if need more info.
Comments
Post a Comment