Created
February 4, 2012 09:57
-
-
Save laiso/1736844 to your computer and use it in GitHub Desktop.
コマンドラインからAmazon.co.jp で買い物するスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env casperjs | |
# | |
# # Run script | |
# casperjs [email protected] amazonpasswd ASIN00001 | |
# | |
# # CasperJS | |
# http://n1k0.github.com/casperjs/ | |
casper = require('casper').create() | |
if casper.cli.args.length isnt 3 | |
casper.log 'Missing required argument. / USER PASS ASIN', 'error' | |
casper.exit() | |
login = casper.cli.args[0] | |
passwd = casper.cli.args[1] | |
asin = casper.cli.args[2] | |
accessLog = ()-> | |
casper.echo casper.evaluate -> document.URL | |
casper.start 'http://www.amazon.co.jp/dp/' + asin, -> | |
accessLog() | |
@evaluate -> document.querySelector('#handleBuy').submit() | |
casper.then -> | |
accessLog() | |
@click 'a.hucSprite.s_checkout.hlb-checkout-button' | |
casper.then -> | |
@echo "LOGIN..." | |
accessLog() | |
@fill 'form#ap_signin_form', | |
"email": login | |
"password": passwd | |
, true | |
casper.then -> | |
@echo "SELECT ADDRESS..." | |
accessLog() | |
@evaluate -> document.forms[1].submit() | |
casper.then -> | |
@echo "SELECT SHIPPINGSPEED" | |
accessLog() | |
@click 'input[name="continue"]' | |
casper.then -> | |
@echo "SELECT OPTION..." | |
accessLog() | |
@click 'input#continue-top' | |
@waitForSelector 'input[name=placeYourOrder]', -> | |
@echo "SUBUMIT SHOPPING" | |
accessLog(@) | |
@click 'input[name=placeYourOrder]', -> | |
accessLog() | |
@echo "NOW COMPLETE!!!" | |
@exit() | |
, null, 12000 | |
casper.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment