Skip to content

Instantly share code, notes, and snippets.

@msg7086
Created January 9, 2021 09:29
Show Gist options
  • Save msg7086/2b8ee2ccce9c46ac4b3ae8ba42c8c263 to your computer and use it in GitHub Desktop.
Save msg7086/2b8ee2ccce9c46ac4b3ae8ba42c8c263 to your computer and use it in GitHub Desktop.
var args = require('system').args;
if (args.length !== 3) {
console.log(args[0] + ' <username> <password>');
phantom.exit();
}
var fs = require('fs');
var page = require('webpage').create();
page.settings.userAgent = 'Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
page.onLoadFinished = function(){
var frm = page.evaluate(function(){
return document.getElementById("login_form");
});
if(frm) return;
var cookies = page.cookies;
for(var i in cookies) {
if(cookies[i].name == 'session_id') {
fs.write("youtube-dl-cookie.txt", "# Netscape HTTP Cookie File\n\n.crunchyroll.com TRUE / FALSE 0 session_id " + cookies[i].value, 'w');
phantom.exit();
}
}
console.log("ERROR cannot find cookie")
phantom.exit();
};
page.open('https://www.crunchyroll.com/login', function() {
page.evaluate(function() {
document.getElementById('login_form_name').value = args[1];
document.getElementById('login_form_password').value = args[2];
document.getElementById('login_form').submit();
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment