[Solved] Simple JS Full Page Web Scraping [closed]


Actually, it is possible to do from javascript.
If another site has CORS enabled, you can use ajax to fetch remote url contents.

If it does not CORS enabled, you can use your own server to fetch remote url contents. So, you can send ajax request to your server, your server will fetch remote contents and give it as a response to your ajax.

Also, you could use JSONP with your server, or if you don’t have your server, you can find online service which provides you with such functionality.

Here, I created an example of fetching remote url by free online service and JSONP: http://jsfiddle.net/pisamce/2t1gz24x/

var res = document.getElementById('res'),
    url = document.getElementById('url')
    myVar="";
window.show = function (jsonp) {
    myVar = jsonp[0].body; //assign response to your variable
    res.innerText = myVar;
}
document.getElementById('btn').addEventListener('click', function () {
    var s = document.createElement('script');
    s.src="http://jsonpwrapper.com/?urls%5B%5D=" + encodeURIComponent(url.value) + '&callback=show';
    document.getElementsByTagName('head')[0].appendChild(s);
});
<input id="url" type="text" value="http://example.com" />
<input id="btn" type="button" value="Get page html" />
<pre id="res"></pre>

solved Simple JS Full Page Web Scraping [closed]