Cookie

Learn how to add your own cookies to a MrScraper scraper so it can reach content that is restricted, personalized, or behind a login session.

Cookies are small pieces of data stored by your web browser that help websites remember your preferences and session information.

In MrScraper, you can use cookies to access content that may be restricted or personalized based on your previous interactions with a website. Here's how to set up and use cookies in MrScraper:

Obtaining Cookies

You’ll first need to extract the cookies from your browser. There are a few ways to do this:

Using Browser Developer Tools

Chrome / Edge / Brave

  1. Open your web browser and navigate to the website you want to scrape.
  2. Open the developer tools (usually by pressing F12 or right-clicking and selecting "Inspect").
  3. Go to the "Application" or "Storage" tab, then find the "Cookies" section.
  4. Select the website's URL to view the cookies stored for that site.
  5. Copy the cookies you need (usually as key-value pairs).

Firefox

  1. Open your web browser and navigate to the website you want to scrape.
  2. Right click on the page and select "Inspect Element" to open the developer tools.
  3. Go to the "Storage" tab, then find the "Cookies" section.
  4. Copy the cookies you need (usually as key-value pairs).

Using Browser Extensions

You can also use browser extensions to quickly view, manage, and export cookies. Popular options include:

Using Cookies in your Scraper

  1. Navigate to your MrScraper dashboard.
  2. click Scraper in the left sidebar, and click on the scraper you want to add cookies to.
  3. Press the ellipsis (three dots) button on the top right corner of the scraper details page.
  4. Select Set Cookies Settings from the dropdown menu.
  5. Paste the JSON cookies you exported earlier into the provided field.
Example Cookie JSON
[
    {
        "domain": "www.example.com",
        "expirationDate": 1764823423.823961,
        "hostOnly": true,
        "httpOnly": false,
        "name": "token",
        "path": "/",
        "sameSite": "strict",
        "secure": false,
        "session": false,
        "storeId": null,
        "value": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImtpemEiLCJleHAiOjE3NjQ4MjM0MjN9.qvviwvaTZDc9ey0iW638cdZr-EdiGHOfKsvTahZ_nIs"
    }
]

Using Cookies with the Scraper API

The Scraper API takes cookies as name=value pairs separated by semicolons, like a browser's Cookie header. In the dashboard, open Advanced Settings in Scrape HTML, Scrape Markdown or Get Screenshot, turn on Set Cookies and paste the pairs. The code examples include them.

From your own code, send them either as the URL-encoded cookies query parameter or as a standard Cookie header:

cookies query parameter
curl --location 'https://api.mrscraper.com?html=true&cookies=session_id%3Dabc123%3B%20lang%3Den&url=https%3A%2F%2Fwww.example.com' \
  -H 'x-api-token: <YOUR_API_TOKEN>'
Cookie header
curl --location 'https://api.mrscraper.com?html=true&url=https%3A%2F%2Fwww.example.com' \
  -H 'x-api-token: <YOUR_API_TOKEN>' \
  -H 'Cookie: session_id=abc123; lang=en'

When both are sent, the cookies parameter wins. A request with cookies is never served from or stored in the result cache.

Note

Cookies often carry a login session. Treat them like a password and do not share code examples that contain them.

On this page