Sha256: 85f28e0d46d9b77d29885847a3c4964cb8508409dafe5ecb08134788e5aee123

Contents?: true

Size: 1022 Bytes

Versions: 17

Compression:

Stored size: 1022 Bytes

Contents

# Get twitter status for given account (or for the default one, "PhantomJS")

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 = (msg) ->
  console.log msg

# Print usage message, if no twitter ID is passed
if system.args.length < 2
  console.log 'Usage: tweets.coffee [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}"), (status) ->
  # Check for page load success
  if status isnt 'success'
    console.log 'Unable to access network'
  else
    # Execute some DOM inspection within the page context
    page.evaluate ->
      list = document.querySelectorAll 'div.tweet-text'
      for i, j in list
        console.log "#{j + 1}: #{i.innerText}"
  phantom.exit()

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
entangled-0.0.16 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
entangled-0.0.15 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
entangled-0.0.14 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
entangled-0.0.13 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
entangled-0.0.12 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
entangled-0.0.11 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/tweets.coffee
entangled-0.0.10 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/tweets.coffee