Web scraping using firefox & jQuery

On November 18, 2010, in Javascript, Launch, Open Source, Tips, Tricks, by Sandeep Verma

Hits: 4701  

Hello Friends,

Today we will scrape HTML from any web page using jQuery and firefox firebug console. This is useful when you want to grab HTML of web page dynamically created by JavaScript or Ajax.

This example is quite useful when you want to extract any web content based on HTML Tag element ID or Class like ‘<div id=”svnlabs”></div>’ or ‘<img src=”svnlabs.jpg” id=”svn_labs”>’

See the code in action here… scraper.txt

jQuery(“body”).append(‘<textarea id=”svnlabs” cols=”70″ rows=”20″></textarea>’);

jQuery(“#svnlabs”).val(jQuery(“body”).html());

OR

copy and paste below code in browser address bar….

javascript: jQuery(“body”).append(‘<textarea id=”svnlabs” cols=”70″ rows=”20″></textarea>’); jQuery(“#svnlabs”).val(jQuery(“body”).html());

You have to post above code in firefox firebug javascript console. The latest jQuery library must be included on that web page you want to scrap ;)
Above two JavaScript lines will add a new textarea in body of same web page to set content of any HTML element. Please make sure after copy the above code; no illegal character in it.

Keep blogging……… ;)







  • Mahesh Patel

    TOTALLY LAMP THING!

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...