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 ...@@ -12,22 +12,22 @@ if casper.cli.args.length == 0
12 casper.exit() 12 casper.exit()
13 13
14 processPage = -> 14 processPage = ->
15 casper.echo "capturing page #{currentPage}" 15 @echo "capturing page #{currentPage}"
16 casper.capture "google-results-p#{currentPage}.png" 16 @capture "google-results-p#{currentPage}.png"
17 17
18 # don't go too far down the rabbit hole 18 # don't go too far down the rabbit hole
19 return if currentPage >= 5 19 return if currentPage >= 5
20 20
21 if casper.exists "#pnnext" 21 if @exists "#pnnext"
22 currentPage++ 22 currentPage++
23 casper.echo "requesting next page: #{currentPage}" 23 @echo "requesting next page: #{currentPage}"
24 #casper.thenClick("#pnnext").then(processPage) 24 #@thenClick("#pnnext").then(processPage)
25 url = @getCurrentUrl() 25 url = @getCurrentUrl()
26 casper.thenClick("#pnnext").then -> 26 @thenClick("#pnnext").then ->
27 check = -> url != @getCurrentUrl() 27 check = -> url != @getCurrentUrl()
28 @waitFor check, processPage 28 @waitFor check, processPage
29 else 29 else
30 casper.echo "that's all, folks." 30 @echo "that's all, folks."
31 31
32 casper.start 'http://google.fr/', -> 32 casper.start 'http://google.fr/', ->
33 @fill 'form[action="/search"]', q: casper.cli.args.join(' '), true 33 @fill 'form[action="/search"]', q: casper.cli.args.join(' '), true
......