aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/tweets.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/tweets.js')
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/tweets.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/tweets.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/tweets.js
new file mode 100644
index 00000000..d3f18c58
--- /dev/null
+++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/tweets.js
@@ -0,0 +1,37 @@
+// Get twitter status for given account (or for the default one, "PhantomJS")
+
+var page = require('webpage').create(),
+ system = require('system'),
+ twitterId = "PhantomJS"; //< default value
+
+// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
+page.onConsoleMessage = function(msg) {
+ console.log(msg);
+};
+
+// Print usage message, if no twitter ID is passed
+if (system.args.length < 2) {
+ console.log("Usage: tweets.js [twitter ID]");
+} else {
+ twitterId = system.args[1];
+}
+
+// Heading
+console.log("*** Latest tweets from @" + twitterId + " ***\n");
+
+// Open Twitter Mobile and, onPageLoad, do...
+page.open(encodeURI("http://mobile.twitter.com/" + twitterId), function (status) {
+ // Check for page load success
+ if (status !== "success") {
+ console.log("Unable to access network");
+ } else {
+ // Execute some DOM inspection within the page context
+ page.evaluate(function() {
+ var list = document.querySelectorAll('div.tweet-text');
+ for (var i = 0; i < list.length; ++i) {
+ console.log((i + 1) + ": " + list[i].innerText);
+ }
+ });
+ }
+ phantom.exit();
+});