This content originally appeared on DEV Community and was authored by Shaswat Raj
WebScrapperJS
WebScrapperJS - Get Content/HTML of any website without being blocked by CORS even using JavaScript by WhollyAPI
Website :- https://sh20raj.github.io/WebScrapperJS/
Grab the CDN or Download the JavaScript File
<script src="https://cdn.jsdelivr.net/gh/SH20RAJ/WebScrapperJS/WebScrapper.min.js" ></script>
To Get HTML Content of Any Website
var url = 'https://google.com/';
var html = WebScrapper.gethtml(url);//html of the url will be stored in this variable
console.log(html);
Intialise own WebScrapper with URL
let MyWebScrapper = new scrapper('https://example.com/');
//You can now directly call gethtml() instead of passing a url into it.
console.log(MyWebScrapper.gethtml()); //Grab https://example.com/ and print on console
Still you can Use new created scrapper MyWebScrapper
for grabbing new URLs. Like
let MyWebScrapper = new scrapper('https://example.com/');
//You can now directly call gethtml() instead of passing a url into it.
console.log(MyWebScrapper.gethtml()); //Grab https://example.com/ and print on console
console.log(MyWebScrapper.gethtml('https://example.com/')); //Grab https://youtube.com/ and print on console
Try this on Codepen
Sample Code | Codepen :- https://codepen.io/SH20RAJ/pen/VwrwjXJ?editors=1001
<div id="scrappedcontent"></div>
<script src="https://cdn.jsdelivr.net/gh/SH20RAJ/WebScrapperJS/WebScrapper.min.js" ></script>
<script>
let MyWebScrapper = new scrapper('https://google.com/');
//You can now directly call gethtml() instead of passing a url into it.
console.log(MyWebScrapper.gethtml()); //Grab https://example.com/ and print on console
var html = MyWebScrapper.gethtml('https://example.com/');
console.log(html); //Grab https://youtube.com/ and print on console
document.getElementById('scrappedcontent').innerHTML = html;
</script>
See Results Here
This content originally appeared on DEV Community and was authored by Shaswat Raj

Shaswat Raj | Sciencx (2022-01-25T12:45:22+00:00) WebScrapperJS – Get Content/HTML of any website without being blocked by CORS even using JavaScript by WhollyAPI. Retrieved from https://www.scien.cx/2022/01/25/webscrapperjs-get-content-html-of-any-website-without-being-blocked-by-cors-even-using-javascript-by-whollyapi/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.