Skip to content

Instantly share code, notes, and snippets.

@vampaynani
Last active September 10, 2017 21:04
Show Gist options
  • Save vampaynani/14c32841559c3dfc094f to your computer and use it in GitHub Desktop.
Save vampaynani/14c32841559c3dfc094f to your computer and use it in GitHub Desktop.
var _ = require('lodash');
var data = {};
var casper = require('casper').create({
viewportSize: {
width: 800,
height: 600
},
clientScripts: [
'include/jquery-1.11.3.min.js',
'include/lodash.min.js'
]
});
var userId = '1665466078';
var iconoUrl = 'http://iconosquare.com/viewer.php#/followers/'+userId;//'https://twitter.com/3rickuribe';
// ========================================
// ! Casper Events
// ========================================
//casper.viewportSize({width: 800, height: 600});
casper.on('remote.message', function(msg){
this.echo(msg, 'DEBUG');
});
// ========================================
// ! Instagram
// ========================================
casper.start('https://www.instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize%3Fclient_id%3Dd9494686198d4dfeb954979a3e270e5e%26redirect_uri%3Dhttp%253A%252F%252Ficonosquare.com%26response_type%3Dcode%26scope%3Dlikes%2Bcomments%2Brelationships', function(response){
var element = '#login-form';
function crawl(){
this.capture('login-instagram.png', {
top: 0,
left: 0,
width: 800,
height: 600
});
}
function onTimeout(){
this.echo('Login Timeout', 'ERROR');
}
if (response == undefined || response.status >= 400) {
this.echo(JSON.stringify({error: 'Handle Instagram does not exists.'}), 'ERROR');
}else{
//Esperar a que cargue la página
casper.waitForSelector(element, crawl, onTimeout, 2000);
}
});
casper.thenEvaluate(function(){
var f = document.querySelector('#login-form');
f.querySelector('#id_username').value = 'cora.chapelle.boutique';
f.querySelector('#id_password').value = 'Buildingmydream8';
f.submit();
});
casper.then(function(){
this.capture('inside.png', {
top: 0,
left: 0,
width: 800,
height: 600
});
});
casper.thenOpen(iconoUrl, function(response){
var element = 'a.followers.user-action-btn';
this.capture(userId+'_init.png', {
top: 0,
left: 0,
width: 800,
height: 600
});
{
"name": "scrapnet",
"version": "1.0.0",
"description": "Social Networks Casper Scraper",
"main": "index.js",
"scripts": {
"dev": "casperjs index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"crawl",
"scrap",
"twitter",
"facebook",
"linkedin"
],
"author": "Creze Dev Team <contacto@creze.com> (https://www.creze.com)",
"license": "MIT"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment