Skip to content

Instantly share code, notes, and snippets.

@naoya
Created October 10, 2013 06:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoya/6914131 to your computer and use it in GitHub Desktop.
Save naoya/6914131 to your computer and use it in GitHub Desktop.
casper = require('casper').create
pageSettings:
loadImages: false,
## amazlet top page
casper.start 'http://app.amazlet.com/', () ->
@echo @getCurrentUrl()
@echo @getTitle()
@fill 'form', keyword: casper.cli.args[0]
@click 'form input[type="submit"]'
## search result
casper.then ->
@echo @getCurrentUrl()
## debug
links = @evaluate ->
links = document.querySelectorAll "p.title a"
Array::map.call links, (e) -> e.text
@echo links[0]
# click on 1sst result link
@click 'a.minibutton'
## get affiliate tag for first item
casper.then ->
@echo @getCurrentUrl()
@echo @evaluate ->
document.getElementById('standard').value
do casper.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment