I'm trying to scrap basic informations from facebook profiles. My final goal is to get for example the age of someone (if the information is accessible on facebook of course) by using casperjs.
So I installed Casper.js. I started by filling my password and mail to get access to the search field in a second time.
But :
ReferenceError: Can't find variable: casper
phantomjs://code/scrapin.js:1 in global code :0 in injectJs phantomjs://code/bootstrap.js:456 Hint: you may want to use the
casperjs test
command.phantomjs://code/bootstrap.js:148 in onPhantomError
Here is my code:
casper.start('https://www.facebook.com/', function() {
this.fill('form[id="login-form"]', {
'username': 'my mail adress',
'password': 'my fb password'
}, true);
});
casper.then(function() {
this.echo(this.getTitle());
});
casper.run();
I precise that Casper.js is working on my computer, it worked for other tasks.
I'm sure it's a basic mistake, I'm totally a beginner on javascript! Please excuse my bad english, I do my best ;)
Thank you!
On top of your script, add this line,
var casper = require('casper').create();
Then when you want to run the script, run it using the following,
casperjs myPreciousScript.js