Parsing HTML without retrieving external resources

Parsing HTML without retrieving external resources

Hi, thanks for reading this, hope you can help.

I am putting together a site that uses screen scraping to extract results from a number of search engines.  The HTML is downloading fine and I am able to extract search engines results relatively easily using the JQuery .find() function.

My problem is that when the HTML is parsed the browser is firing requests for external resources (i.e. image & video files) that are referenced within the parsed HTML.  These resources are not required by my site (I only extract the text results and don't want to display images) and just waste the user's bandwidth.

Is it possible to parse the HTML without evaluating embedded resources?

From using Fiddler and Firebug I have determined that the requests are being made during execution of this function:

  1. function getResultSetFromDocument(document) {
  2.       // object that will be returned containing result objects
  3.       var results = new ResultSet(that.engineName);
  4.       // loop through all relevant elements to extract results
  5.       $(document).find('#res ol li').each(function(i) {
  6.             var link = $(this).find('h3 a');
  7.             var text = link.text();
  8.             var href = link.attr('href');
  9.             var description = $(this).text();
  10.             // create new result object to add to result set for later ranking etc.
  11.             if((href) && (text)) {
  12.                   var result = new WebResult(text, href, i + 1);
  13.                   result.setDescription(description);
  14.                   results.results.push(result);
  15.             }
  16.       });
  17.       return results;
  18. }