Created
July 5, 2015 03:13
-
-
Save zanycadence/ff7acf1307d3f2275a2a to your computer and use it in GitHub Desktop.
CasperJS script to connect a weaved device and output the proxy address
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
var casper = require('casper').create(); | |
var username = 'YOUR_USERNAME'; | |
var password = 'YOUR_PASSWORD'; | |
var deviceId = 'YOUR_DEVICE_ID'; | |
var loginURL = 'https:/developer.weaved.com/portal/login.php' ; | |
var connectURL = 'https://developer.weaved.com/portal/members/ajaxAPI.php?action=connect&id='; | |
casper.start(loginURL, function() { | |
// input username and password | |
this.fill('form#submitForm', { | |
'username': username, | |
'password': password | |
}, true); | |
}); | |
casper.thenOpen(connectURL + deviceId, function(){ | |
//parse JSON and output | |
var data = JSON.parse(this.getHTML('body')); | |
this.echo(data.connection['proxy']); | |
}); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment