Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var system = require('system');
- var os = system.os;
- console.log(os.name);
- var args = system.args;
- var name = args[1]
- var url = args[2];
- var page = require('webpage').create();
- phantom.onError = function(msg,trace){
- var msgStack = ['PHANTOM ERROR : '+ msg];
- if(trace && trace.length){
- msgStack.push('TRACE:');
- trace.forEach(function(t){
- msgStack.push(' -> ' + (t.file || t.sourceURL) + ': ' + t.line + (t.fail));
- });
- }
- console.log(msgStack.join('\n'));
- phantom.exit(1);
- }
- if(args.length < 2){
- throw new Error('Name argument is missing');
- }
- page.viewportSize = { width : 1920 , height :1080};
- var postBody = 'username:fasalirr@gmail.com&password:fasal123';
- page.customHeaders = {
- "Authorization" : "Basic ZmFzYWxpcnJAZ21haWwuY29tOmZhc2FsMTIz"
- };
- page.open(url, 'POST',postBody, function (status){
- console.log('**************************************');
- console.log(status);
- var cookies = page.cookies;
- var addCookie;
- console.log('Listing cookies:');
- for(var i in cookies) {
- console.log(cookies[i].name + '=' + cookies[i].value + cookies[i].domain+cookies[i].path+cookies[i].httponly+cookies[i].secure);
- }
- var addCookie = phantom.addCookie({
- 'name' : cookies[i].name, /* required property */
- 'value' : cookies[i].value, /* required property */
- 'domain' : cookies[i].domain,
- 'path' : cookies[i].path,
- 'httponly' : cookies[i].httponly,
- 'secure' : cookies[i].secure
- });
- // page.open("http://api.staging.etobee.com/", function(statusData){
- // console.log(statusData);
- // var content = page.content;
- // console.log(content);
- // })
- //
- //console.log('Opened '+ url + 'with status: '+ status);
- page.render('image.jpeg',{format : 'jpeg', quality : '100'});
- phantom.exit();
- });
- var test = phantom.cookiesEnabled{true};
- console.log(test);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement