Commit 5f759b5f 5f759b5ff39f1718ad2dcccb9da31f87d877f4e2 by Nicolas Perriault

googlepagination.coffee: use 'this' where applicable

1 parent dfa2c402
......@@ -12,22 +12,22 @@ if casper.cli.args.length == 0
casper.exit()
processPage = ->
casper.echo "capturing page #{currentPage}"
casper.capture "google-results-p#{currentPage}.png"
@echo "capturing page #{currentPage}"
@capture "google-results-p#{currentPage}.png"
# don't go too far down the rabbit hole
return if currentPage >= 5
if casper.exists "#pnnext"
if @exists "#pnnext"
currentPage++
casper.echo "requesting next page: #{currentPage}"
#casper.thenClick("#pnnext").then(processPage)
@echo "requesting next page: #{currentPage}"
#@thenClick("#pnnext").then(processPage)
url = @getCurrentUrl()
casper.thenClick("#pnnext").then ->
@thenClick("#pnnext").then ->
check = -> url != @getCurrentUrl()
@waitFor check, processPage
else
casper.echo "that's all, folks."
@echo "that's all, folks."
casper.start 'http://google.fr/', ->
@fill 'form[action="/search"]', q: casper.cli.args.join(' '), true
......