Skip to content

Instantly share code, notes, and snippets.

@toctan
Last active December 20, 2015 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toctan/6155338 to your computer and use it in GitHub Desktop.
Save toctan/6155338 to your computer and use it in GitHub Desktop.
casper = require('casper').create()
casper.start 'http://v2ex.com/signin'
casper.then ->
@fill 'form[action=\"/signin\"]',
'u': 'username'
'p': 'password'
, true
casper.waitForUrl /v2ex\.com\/$/, ->
if @visible 'a[href=\"/mission/daily\"]'
@click 'a[href=\"/mission/daily\"]'
else
@echo('Today\'s bonus has been claimed.').exit()
, -> @echo(@fetchText '.problem ul li').exit()
casper.then ->
@click '#Main input'
casper.then ->
throw new Error if @fetchText '.message' isnt '已成功领取每日登录奖励'
casper.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment