source: other-projects/FileTransfer-WebSocketPair/Themes/themebuilder/bin/phantomjs-1.9.2-windows/examples/tweets.coffee@ 31525

Last change on this file since 31525 was 31525, checked in by ak19, 7 years ago

Nathan provided more stuff: Themes folder contains Sencha's Themebuilder which generates GXT Themes. It includes the .theme and generated .jar files for the project theme.

File size: 1022 bytes
Line 
1# Get twitter status for given account (or for the default one, "PhantomJS")
2
3page = require('webpage').create()
4system = require 'system'
5twitterId = 'PhantomJS' #< default value
6
7# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
8page.onConsoleMessage = (msg) ->
9 console.log msg
10
11# Print usage message, if no twitter ID is passed
12if system.args.length < 2
13 console.log 'Usage: tweets.coffee [twitter ID]'
14else
15 twitterId = system.args[1]
16
17# Heading
18console.log "*** Latest tweets from @#{twitterId} ***\n"
19
20# Open Twitter Mobile and, onPageLoad, do...
21page.open encodeURI("http://mobile.twitter.com/#{twitterId}"), (status) ->
22 # Check for page load success
23 if status isnt 'success'
24 console.log 'Unable to access network'
25 else
26 # Execute some DOM inspection within the page context
27 page.evaluate ->
28 list = document.querySelectorAll 'div.tweet-text'
29 for i, j in list
30 console.log "#{j + 1}: #{i.innerText}"
31 phantom.exit()
Note: See TracBrowser for help on using the repository browser.