Cookies

cookies: object[] | [];

What's This?

Cookies are tiny bits of data websites use to remember things about you, like if you're logged in or your preferred site settings. The cookies option allows you to give the scraper specific cookies to use when it visits a website, which can affect what the website shows the scraper.

Properties

  • name: The name or identifier of the cookie.

  • value: The information or setting the cookie is holding.

  • domain: The website the cookie is associated with.

How Does it Work?

By default, the scraper doesn't use any special cookies when it visits a website. But if you provide them:

  • Default (cookies=[]): No custom cookies are sent with the request.

  • Example: If you set cookies=[ { name: "username", value: "John", domain: "example.com" }], the scraper will act as if the user "John" is visiting "example.com".

When Should I Use This?

If you want the scraper to see a website the way a specific user would or if there's content that only shows up when certain cookies are present, use the cookies option. It's like giving the scraper a special key to access certain parts or versions of a website.

Methods

addCookie(object) 

Configuration Name: cookies

Use this to add cookies to the scrapers configuration

Initializing Scraper

const GeonodeScraperApi = require('geonode-scraper-api');
const scraper = new GeonodeScraperApi('<Your_username>', '<Your_password>');

Using Method

const cookie = { name: 'cookie1', value: 'value1' };
scraper.addCookie(cookie);
scraper.scrape('https://example.com/');

Using Configuration Object

const config = { cookies: [{ name: 'cookie1', value: 'value1', domain: 'https://example.com' }] };
scraper.scrape('https://example.com/', config);