The Bot 2 : How to make a browserless web scraper?

We will continue from our last post, which discussed about how to make a simple bot that accesses webpages anonymously.
The bot there worked fine, but there are some drawbacks with that bot.
For ex- It used browsers to open webpages, which makes it little slow. Also, it leads to usage of more memory and storage(though cache can be cleared regularly). For sometimes, when the browser is closed forcefully, then it may pop up a dialog box asking to whether open the firefox in safe mode or reset it. This interrupts the automation of the bot. Now you have to reset the firefox proxy settings.

Now, in this post we will create a web scraper(the bot 2) that access web pages without webbrowsers ( browserless web scraper ). We are going to use phantomJs as a headless browser(executes javascript on the web page) and bash to automate it.

We will make two files phantomBot.js and,


var page = require('webpage').create();
var system = require('system');
page.settings.resourceTimeout = 10000;
page.onResourceTimeout = function(error){

page.onResourceReceived = function(response){

if (system.args.length===1){
console.log(“Enter Url”);
}else {[1], function(status){
if (status===’success’){
var title = page.evaluate(function(){
return document.title;

1- page is a webpage object.
2- system is the object to receive command line variables
3- timeout for page load is set.
4- function is defined to be called on timeout.
5- function is defined to be called on successful data receive.
6- check if the url is passed in the command line.
7- open the url using the webpage object(page).
8- read the title of the document on successful load of the url.
9- exit the phantom.

sudo service tor restart
array=("" "")
for item in ${array[*]}
sudo phantomjs --proxy= --proxy-type=socks5 phantomBot.js $item
sudo bash

1- tor is restarted to change the users ip.
2- an array of links that gives you money on getting traffic.(Do not leave spaces after or before ‘=’ sign)
3- iterate through each url and pass them to phantomjs program phantomBot.js to get them opened.
4- re-run the program.

To start the execution of bot, type bash in command line.

Great, you have created little more efficient bot ( browserless web scraper ).
Read websites’ terms, take your own risks and enjoy free money. 🙂

Latest Comments
  1. Satys August 9, 2016

Leave a Reply

Your email address will not be published. Required fields are marked *