Created
March 21, 2016 09:36
-
-
Save nerder/7176f55d711cf64a892a to your computer and use it in GitHub Desktop.
This file contains hidden or 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({ | |
remoteScripts: [ | |
'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', | |
'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.6.1/lodash.js' | |
], | |
pageSettings: { | |
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.1500.71 Safari/537.36' | |
}, | |
viewport: { | |
width: 1280, | |
height: 1024 | |
}, | |
waitTimeout: 60000, | |
logLevel: 'debug', | |
verbose: true | |
}); | |
casper.start('https://web.whatsapp.com/', function(){ | |
this.echo('Starting...') | |
this.waitForSelector('.qrcode', function() { | |
this.captureSelector('whatsapp.png', 'html'); | |
this.echo('Screeshot Taken!') | |
}); | |
}); | |
casper.run(); |
This file contains hidden or 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 system = require('system'); | |
var page = new WebPage(); | |
page.settings.userAgent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.1500.71 Safari/537.36'; | |
page.viewportSize = {width: 1280, height: 1024}; | |
console.log(page.settings.userAgent); | |
page.open('https://web.whatsapp.com/', function (status) { | |
if (status !== 'success') { | |
output.errors.push('Unable to access network'); | |
} else { | |
window.setTimeout(function () { | |
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js",function() { | |
page.clipRect = { | |
top: 214, | |
left: 296, | |
width: 250, | |
height: 250 | |
} | |
page.render('whatsapp_qrcode.jpeg', {format: 'jpeg', quality: '100'}); | |
console.log('QrCode Saved!'); | |
phantom.exit(); | |
}); | |
}, 10500); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment