bypasscors

Bypass CORS restrictions to get data from external domains using the NodeJs server. Setup a get route on your server that you can call from the client and pass it the URL you want to retrive:",

Usage no npm install needed!

<script type="module">
  import bypasscors from 'https://cdn.skypack.dev/bypasscors';
</script>

README

NPM

Bypass CORS restrictions on external domains from Node.js server, scraping any webpage data's as a HTML DOM to make your own APIs. Relative paths for resources will still load using target page's domain.

On the server, setup a route to which the client can pass the URL of the page to retrive:

app.get('/geturl', function(req,res){
    require('bypasscors')(req.query.url, function(html){
        return res.send(html);
    });
});

On the frontend, you can use jQuery to parse the HTML as DOM :

$.get('/geturl', {url: "http://google.com"}, function(html){
    $(html).find("div")
})

Example:

npm i bypasscors express
node node_modules/bypasscors/example