How to scrape a website that requires login?
Tags: cookies, webscraping, webdev, showdev
Published: 2020-11-13 00:54:19

---
title: How to scrape a website that requires login?
published: true
date: 2020-11-09 22:04:24 UTC
tags: cookies,webscraping,webdev,showdev
canonical_url: https://dataflowkit.com/blog/how-to-pass-cookies-to-a-scraper-from-a-web-browser/
---

 ![How to Log in to a website by passing cookies to a web scraper?](https://dataflowkit.com/blog/content/images/2020/11/transfer-cookies--3-.png)

Many websites demand users to register or login before they provide any information. Browsers store cookies for each session as the user navigates the website. Other websites may show pop-ups if they do not have location cookies or if the user explicitly consents to the collection of their data.

Indeed, you can simulate user input to enter credentials, click a button to submit a form. Sometimes, you need to press a checkbox to accept website terms while scraping the data.

Another way is to pass session cookies when you send a request to a website. This article will show how to transfer cookies from a web browser to a Dataflow Kit web scraper.

### Follow the instructions described below to crawl specific websites that require login:

1. Install [EditThisCookie](http://www.editthiscookie.com/) extension to your web browser.
2. Go to the website that you want to crawl and sign in with your credentials.

![How to Log in to a website by passing cookies to a web scraper?](https://dataflowkit.com/blog/content/images/2020/11/transfer-cookies-open--1--1.png)<figcaption>Open a website to scrape.</figcaption>

3.  Open the "EditThisCookie" extension by clicking the button next to your URL. Copy the cookies to the clipboard using the "Export" button.

![How to Log in to a website by passing cookies to a web scraper?](https://dataflowkit.com/blog/content/images/2020/11/transfer-cookies-export.png)<figcaption>Export cookies to JSON Array format</figcaption>

4.  Now paste cookies (Ctrl + V) from the clipboard into the "Initial cookies" field of a Dataflow Kit scraper. Cookies in JSON array format are compatible with the cookie format used by Dataflow Kit.

As an example, we'll use the Dataflow Kit [Screen Capture Service](https://dataflowkit.com/url-to-screenshot) to illustrate the cookie transfer function.

![How to Log in to a website by passing cookies to a web scraper?](https://dataflowkit.com/blog/content/images/2020/11/transfer-cookies-paste.png)

That's all! Now you run the scraper, and it starts already logged in.

### Result

![How to Log in to a website by passing cookies to a web scraper?](https://dataflowkit.com/blog/content/images/2020/11/transfer-cookies-result.png)

In the captured screenshot, we can see that it was captured after the login page.

{% youtube 2zhv0mehlHI %}

* * *

You are not limited to transferring the initial cookies only to the Dataflow Kit services provided on our website. You can add initial cookies to any custom web scraper powered by the Dataflow Kit framework. You can customize your payloads at [https://account.dataflowkit.com/tasks](https://account.dataflowkit.com/tasks)

![How to Log in to a website by passing cookies to a web scraper?](https://dataflowkit.com/blog/content/images/2020/11/custom-payload.png)<figcaption>Custom tasks</figcaption>

You can customize any Task payload and add InitialCookies manually to request.

![How to Log in to a website by passing cookies to a web scraper?](https://dataflowkit.com/blog/content/images/2020/11/Add-cookies-to-request.png)<figcaption>Add Initial Cookies to your payloads</figcaption>

* * *

Depending on a scraped website, cookies may be short-lived, and this approach with passing initial cookies is not a way to go.  In this case, the right solution is to use actions to simulate filling out forms and pressing the submit button.