Skip to main content


Showing posts from April, 2016

"A Simple Recursive Web Page Crawler to Scrape Data" written in Python

I am very new to python language. I bet there are better tools or modules written professionally. But I somehow find this very code written by myself useful. So I wanted to share it online. 
Lets say that we aim to scrape a specific kind of data (E.g. e-mail information is a good data type to try this code on) from within an html based web site. This code visits all possible links she finds and visits them recursively to find data you're seeking. If the web site is designed in a proper format you can inspect the code and identify a few html tags appearing just before the data string you need. 
Of course this code will not work properly if you don't make the necessary adjustments specific for your case. I just wanted to give a general idea to grasp the logic behind recursively crawling a web page and scraping any data.

In crawl() function  I give a random time break between consecutive requests in order not to disturb the server site much. It is a good idea to give that kind of br…