BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / phantomjs-prebuilt / lib / phantom / examples / phantomwebintro.js

phantomwebintro.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
phantomwebintro.js 622 B Download Raw
1// Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
2
3"use strict";
4var page = require('webpage').create();
5
6page.onConsoleMessage = function(msg) {
7 console.log(msg);
8};
9
10page.open("http://phantomjs.org/", function(status) {
11 if (status === "success") {
12 page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
13 page.evaluate(function() {
14 console.log("$(\".explanation\").text() -> " + $(".explanation").text());
15 });
16 phantom.exit(0);
17 });
18 } else {
19 phantom.exit(1);
20 }
21});