I’m trying to do a screen scrape using jquery in a PhoneGap application. The problem is that when I load the target HTML into the current dom so I can use selectors, it attempts to execute the javascript:
$(function() {
$.get('http://www.bloomberg.com/quote/csfb:ind', function(data) {
var elements = $("<div>").html(data)[0].getElementsByClassName("price")[0];
});
});
The get works fine and pulls in the html, but once it starts loading, it tries to execute the javascript.
Is there anyway to strip out all javascript tags?
This seems like the most reliable way as any parsing you come up with on your own may not work in all cases.
Removing all script tags from html with JS Regular Expression
If I copy the stripScripts function from that answer: