mardi 16 mars 2021

fetch url with cookies

so im scrapping a web and i need to use a specific cookies but i dont know how to exactly use "fetch"

    const url="https://www.example.com";
    let response = await fetch(url),
        html = await response.text();

    let $ = cheerio.load(html)

    var example= $('.exampleclass').text();  

Now i can scrap the web but in case i would have to use a specific cookies i dont know how to put in on the fetch.

In python was something like that

response = requests.get(url, headers=headers, cookies=cookies)

Thank you!




Aucun commentaire:

Enregistrer un commentaire