Last active
December 15, 2015 22:19
-
-
Save 2xyo/5331717 to your computer and use it in GitHub Desktop.
Bitcasa command-line interface with Casper.js
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({ | |
verbose: true, | |
logLevel: "debug", | |
waitTimeout: 300000 | |
}); | |
casper.start('https://my.bitcasa.com/', function() { | |
// search for 'casperjs' from google form | |
this.fill('form[action]', { | |
"user": "EMAIL", | |
"password": "PASSSWORD" | |
}, true); | |
}); | |
casper.then(function() { | |
// Click on 1st result link | |
this.captureSelector('0-form.png', 'html'); | |
}); | |
casper.then(function() { | |
// Click on 1st result link | |
this.click('form button'); | |
}); | |
casper.wait(10000, function() { | |
this.echo("I've waited for 10 seconds."); | |
}); | |
casper.then(function() { | |
// Click on 1st result link | |
this.captureSelector('1-10.png', 'html'); | |
}); | |
casper.waitForSelector('article.ng-scope', function() { | |
this.captureSelector('2-Done.png', 'html'); | |
}); | |
/** | |
var data, wsurl = 'https://portal.bitcasa.com/uploader/download-to-bitcasa'; | |
casper.waitForSelector('article.ng-scope',function() { | |
data = this.evaluate(function(wsurl) { | |
return JSON.parse(__utils__.sendAJAX( | |
wsurl, | |
'POST', | |
{ | |
'file': 'http://yYOURFILE', | |
'cookie': JSON.stringify([]) | |
}, | |
false | |
)); | |
}, {wsurl: wsurl}); | |
}); | |
**/ | |
var data; | |
casper.thenOpen('https://portal.bitcasa.com/uploader/download-to-bitcasa', { | |
method: 'post', | |
data: { | |
'file': 'http://YOURFILHERE', | |
'cookie': '', | |
'cookies': JSON.stringify([]) | |
}, | |
headers: { | |
'Accept-Language': 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3', | |
'Origin': 'chrome-extension://jbbedjcjllhecelfnfofhgcimmakkbon', | |
'User-Agent': 'Mozilla/5.0 (X11; Linux) AppleWebKit/537.32 (KHTML, like Gecko) Chrome/27.0.0453.14 Safari/527.36', | |
'X_REQUESTED_WITH': 'XMLHttpRequest' | |
} | |
}); | |
casper.then(function() { | |
require('utils').dump(data); | |
}); | |
casper.then(function() { | |
// Click on 1st result link | |
this.captureSelector('3-post.png', 'html'); | |
}); | |
casper.then(function() { | |
this.echo('POSTED it.'); | |
}); | |
casper.on('resource.requested', function(resource) { | |
this.echo('<' + JSON.stringify(resource)); | |
}); | |
casper.on('resource.received', function(resource) { | |
this.echo('>' + JSON.stringify(resource)); | |
}); | |
casper.on('open', function(location, settings) { | |
this.echo('>>' + JSON.stringify(location)); | |
this.echo('>>' + JSON.stringify(settings)); | |
}); | |
casper.run(); |
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
POST /uploader/download-to-bitcasa HTTP/1.1 | |
Host: portal.bitcasa.com | |
Connection: keep-alive | |
Content-Length: 124 | |
Accept: */* | |
Origin: chrome-extension://jbebdjcjllheeclffnofhgcimmlkkbon | |
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.22 (KHTML, like Gecko) Ubuntu Chromium/25.0.1364.160 Chrome/25.0.1364.160 Safari/537.22 | |
X_REQUESTED_WITH: XMLHttpRequest | |
Content-Type: application/x-www-form-urlencoded; charset=UTF-8 | |
DNT: 1 | |
Accept-Encoding: gzip,deflate,sdch | |
Accept-Language: en-US,en;q=0.8,fr;q=0.6 | |
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 | |
Cookie: optimizelyEndUserId=oeu13684303; optimizelySegments=%7B%7D; optimizelyBuckets=%7B%7D; portal_csrftoken=53556f2fffd4; sam=3580125647557646744bbb7; _chartbeat2=r561001; portal_sessionid=50bd0fc | |
file=http%3A%2F%2Fcdimage.debian.org%2Fdebian-cd%2F6.0.7%2Fi386%2Fiso-cd%2Fdebian-6.0.7-i386-CD-2.iso&cookie=&cookies=%5B%5D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks promising, I am just a little unclear as to how to utilize this script..? I have bitcasa and would like to connect to my host via ssh and open a tunnel to bitcasa. This way I can backup my sites without having to download the sites to my (ssd) hard drive. Any guidance in getting this done?