Friday, 15 March 2013

Getting the HTML, CSS and JavaScript of a site with JavaScript -



Getting the HTML, CSS and JavaScript of a site with JavaScript -

i've seen many questions scraping html jquery + node.js + yql. makes no mention of getting the css , javascript webpage.

is there way html, css , javascript of external website without using server side techniques?

*i need happen in code can utilize results in webapp.

possible duplicate of this. reply lies here.

you should check out jquery. has rich base of operations of ajax functionality can give powerfulness of this. can load in external page, , parse it's html content intuitive css-like selectors.

an illustration using $.get();

$.get("anotherpage.html", {}, function(results){ alert(results); // show html anotherpage.html alert($(results).find("div.scores").html()); // show "scores" div in results });

for external domains i've had author local php script deed middle-man. jquery phone call local php script passing in server's url argument, local php script gather data, , jquery read info local php script.

$.get("middleman.php", {"site":"http://www.google.com"}, function(results){ alert(results); // middleman gives google's html jquery });

note: php thing different domains.

javascript

No comments:

Post a Comment