For a recent analysis project, I had to capture all links to feed into my scraper to gather data on residential prices in various cities in India.

Getting the links to feed into my scraper could be done manually or well quasi-automated!

Let's look at the way I can use jQuery to make the job simple!

First, the data I needed to capture was in the HTML table at NHB.

I need to browse through various cities for the scraper.

First, select the links using jQuery

var links = $('div.general table').first().find('tr').first().find('a')  

Second, cycle through the links and capture the link href values in the array!

var indices = []

$.each(links, function(index, link) {
 indices.push("" + $(link).attr('href'));


Third? No third step! ;-)

Capturing links as an array from HTML using jQuery

Blog Logo


Ghost Lover!



Random Thoughts!

Fast and Mobile Life!

Back to Overview