0
我是Phantomjs和JavaScript本身的新手,但出於某種原因,我得到的錯誤是即使我聲明變量用戶名並且它是全局變量也無法找到。無法找到變量
var page = require('webpage').create();
var system = require("system");
page.open('https://www.facebook.com/login.php?login_attempt/', function(status) {
page.includeJs('https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', function() {
var username = "test";
var password = "test";
page.evaluate(function() {
$("#email").val(username);
$("#pass").val(password);
$("#loginbutton").click();
});
page.onLoadFinished = function() {
page.render("after_submit.png");
if (page.url == "https://www.facebook.com/") {
var fs = require('fs');
var path = 'succes.txt';
var content = "Facebook : \n" + username;
fs.write(path, content, 'w');
}
phantom.exit();
};
page.render("before_submit.png");
});
});