Using CasperJS to scrape website data

Installing PhantomJS:

sudo apt-get install libfontconfig1
cd /opt
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2
tar xjf phantomjs-1.9.1-linux-x86_64.tar.bz2
rm -f phantomjs-1.9.1-linux-x86_64.tar.bz2
ln -s phantomjs-1.9.1-linux-x86_64 phantomjs
sudo ln -s /opt/phantomjs/bin/phantomjs /usr/bin/phantomjs

Installing CasperJS:

cd /opt/
git clone git://github.com/n1k0/casperjs.git
cd casperjs
ln -sf `pwd`/bin/casperjs /usr/local/bin/casperjs
phantom.casperTest = true;
var fs = require('fs');
var utils = require('utils');
var casper = require('casper').create({
pageSettings: {
loadImages: false, // The WebPage instance used by Casper will
loadPlugins: false, // use these settings
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36'
}
});
url = <url-of-login-page>casper.start(url, function() {
// replace in below format form.<class-name> or form#<form-id>
this.fill('form.<form-class>', {
email: <enter-email-id-here>,
password: <enter-password-here>
}, true);
});
casper.then(function() {
this.echo(this.getTitle());
});
casper.run();

The article was originally published at MicroPyramid blog

--

--

--

Python, Django, Android and IOS, reactjs, react-native, AWS, Salesforce consulting & development company

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

From RhinoJS To NodeJS. Enhanced With worker_threads 🚀

Load data from S3 to Redshift

React Hot Reload in Ruby On Rails

IT LIVES! My Discord Bot Development has Begun

Check selenium-grid configuration

To Add Firebase to you JavaScript Project

How to Build Your Own Weather Station Using a Raspberry Pi

STYLED COMPONENTS + STYLED SYSTEM = SUPER POWER PART I

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
MicroPyramid

MicroPyramid

Python, Django, Android and IOS, reactjs, react-native, AWS, Salesforce consulting & development company

More from Medium

3 Easy Ways to import a shapefile into a PostgreSQL database

CRUD Operations on Essential RDBMS’ in Python Language

Fun Personality check with REST API in 7 minutes.

Build a WhatsApp Chatbot With Python

Build a WhatsApp Chatbot With Python — ultramsg