Files
phantomjs/examples/phantomwebintro.js
petercoles d831dea8c8 Update example
Since this example was written the phantomjs home page has been redesigned and the targeted ID no longer exists. This tweaks the example so that it can again find content to report.
2014-03-29 11:09:51 +00:00

20 lines
577 B
JavaScript

// Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("http://www.phantomjs.org", function(status) {
if ( status === "success" ) {
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
page.evaluate(function() {
console.log("$(\".explanation\").text() -> " + $(".explanation").text());
});
phantom.exit();
});
}
});