Created
September 20, 2014 00:56
-
-
Save atorralb/b41a40f85bdea4a69c24 to your computer and use it in GitHub Desktop.
This is a nice way to show you how to follow links or tell phantomjs how to proceed aftter opening each link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var username = "you"; | |
var password = "passord" | |
var page = require("webpage").create(); | |
page.open("http://facebook.com",function(){ | |
// step 2 | |
page.onLoadFinished=function(){ | |
// step 4 | |
page.onLoadFinished = function(){ | |
// step 6 | |
page.onLoadFinished = function(){} | |
// step 5 | |
page.evaluate(function(){ | |
document.querySelector("textarea").value="hello world!!! sent by phantomjs."; | |
document.querySelector("form[action*=updatestatus]").submit(); | |
}) | |
// step 7 | |
window.setTimeout(function(){ | |
page.render("/tmp/facebook_result.png"); | |
phantom.exit(); | |
},3000); | |
} | |
// step 3 | |
page.evaluate(function(){ | |
var link = document.querySelector("a[href*=profile]"); | |
location.href=link.href; | |
}); | |
} | |
// step 1 | |
page.evaluate(function(arr){ | |
document.querySelector("#email").value=arr[0]; | |
document.querySelector("#pass").value=arr[1]; | |
document.querySelector("#login_form").submit(); | |
},[username,password]); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment