Created
August 21, 2012 18:09
-
-
Save kageroh/3417986 to your computer and use it in GitHub Desktop.
PhantomJS 事始め (某バゲーにログインするの巻)
This file contains 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
(function () { | |
var args = { | |
id : phantom.args[0], | |
pw : phantom.args[1] | |
}; | |
var urls = [ | |
'https://ssl.sp.mbga.jp/_lg' | |
]; | |
var page = require('webpage').create(); | |
page.settings.userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3'; | |
var url = ''; | |
page.onUrlChanged = function (new_url) { | |
url = new_url; | |
}; | |
var num = 0; | |
page.onLoadFinished = function () { | |
page.render( (num++).toString(10) + '.png' ); | |
switch (url) { | |
case urls[0] : | |
page.evaluate(function (args) { | |
var form = document.forms[0]; | |
form.login_id.value = args.id; | |
form.login_pw.value = args.pw; | |
form.submit(); | |
}, args); | |
break; | |
default : | |
phantom.exit(); | |
break; | |
} | |
}; | |
page.open(urls[0]); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment