I'm using PhantomJS to login website and the captcha has to be inputed manually. How can I save the captcha image to disk, and then input the captcha by hand in PhantomJS console?
I had the same problem, just use the system module in combination with a page.render() and some argument passing to page.evaluate.
page.render('pagewithcatpcha.jpg');
page.injectJs('http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js');
var arg1 = consoleRead();
page.evaluate(function (arg1) {
$('.yourFormBox').val(arg1);
$('.yourForm').submit();
}, arg1);
function consoleRead() {
var system = require('system');
system.stdout.writeLine('CaptchaCode: ');
var line = system.stdin.readLine();
return line;
}
What you're asking sounds nearly impossible.
If I were desperate to do something like this I might consider the following approach:
/tmp/code.txt
) with capture result/tmp/code.txt
It's not pretty. But I can't think of any other way off the top of my head.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With