page.includeJs() jQuery , ( page.evaluate()). , phantom.exit() , window.phantom.
.
AJAX
jQuery.ajax() async: false, AJAX, , .
page.open(url, function (status) {
page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', function () {
console.log("Solve Captcha");
page.evaluate(function(){
$.ajax({
async: false,
url: 'http://localhost/captcha.php',
data: { filename: 'C:\\wamp\\www\\images\\0.png' },
type: 'post',
success: function (output) {
console.log('Solved');
},
});
});
phantom.exit();
});
});
waitFor . success AJAX:
page.open(url, function (status) {
page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', function () {
console.log("Solve Captcha");
page.evaluate(function(){
window._finishedCall = false;
$.ajax({
url: 'http://localhost/captcha.php',
data: { filename: 'C:\\wamp\\www\\images\\0.png' },
type: 'post',
success: function (output) {
console.log('Solved');
window._finishedCall = true;
},
});
});
waitFor(function check(){
return page.evaluate(function(){
return window._finishedCall;
});
}, function onReady(){
phantom.exit();
}, 10000);
});
});
, - , captcha.php localhost, url localhost. PhantomJS --web-security=false URL-: http://localhost/captcha.php.