I am trying to do some simple webscraping in javascript to get the html code from either delish or tasty sites to store recipes. one example would be this site: https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe/ However when I use fetch I am not able to get it to work.
I actually wrote the equivalent code in python that I want to be able to translate into javascript. This is pasted here:
import requests
url = "https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe/"
r = requests.get(url)
text = str(r.content)
I am able to get the javascript code to work when I use a different site. For example this worked for me
fetch('https://api.github.com/users/maecapozzi')
.then(res => console.log('response: ', res))
.catch(console.error)
but when trying for my site I got an error:
Access to fetch at 'https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. index.js:1375 TypeError: Failed to fetch
I am not sure what exactly this means as I am pretty new to all this, so any help at all would be greatly appreciated!