---
title: "How to Use Crawlee for Web Scraping: A Step-by-Step Tutorial"
description: "Discover practical strategies for efficient web scraping and automation with Crawlee. Streamline your data collection processes."
url: "https://iproyal.com/blog/crawlee-web-scraping-tutorial/"
---

- [EN - English](https://iproyal.com/)
   
  [中文 - Chinese](https://iproyal.cn/)

[Book a Demo](https://iproyal.com/request-a-demo/) [Create Account](https://dashboard.iproyal.com/register/) [Create Account](https://dashboard.iproyal.com/register/) [Login](https://dashboard.iproyal.com/login/) [Login](https://dashboard.iproyal.com/login/)

[Book a Demo](https://iproyal.com/request-a-demo/)

[Back to blog](https://iproyal.com/blog/)

# How to Use Crawlee for Web Scraping: A Step-by-Step Tutorial

[Vilius Dumcius](https://iproyal.com/blog/authors/vilius-dumcius/)

[Last updated - July 24, 2025 ‐ 5 min read](https://iproyal.com/blog/authors/vilius-dumcius/)

[Tutorials](https://iproyal.com/blog/category/tutorials/)

Web scraping is a popular method to gather data from websites automatically, be it product price data, company-related information, reviews, or more. And **instead of having to do all that manually, which would take ages, Crawlee steps in to help.**

**Crawlee makes web scraping and browser automation fast, intuitive, and reliable.&#x20;**&#x49;n this tutorial, you will learn how to install Crawlee, set it up, and build a simple web scraper step by step.

## What Is Crawlee?

Crawlee is an open-source browser automation library for Node.js. **It lets you control headless browser or HTTP sessions,&#x20;**&#x68;elping you perform both web scraper and browser automation with ease.

Unlike other popular tools, **Crawlee combines both HTTP requests and JavaScript, providing flexible options for fetching and processing data.&#x20;**&#x49;t means you no longer need to limit yourself to static HTML pages since Crawlee can also scrape dynamic pages.

## Key Features of Crawlee

- Easy crawler setup with both headless browsers and HTTP clients.
- Built-in support for proxy rotation and concurrency.
- Automatic retry and error handling.
- Data export to files like JSON or CSV.
- Integration with popular tools like browser automation library frameworks.

## Why Use Crawlee for Web Scraping

**Crawlee speeds up web scraping by automating tasks you’d otherwise have to do manually.&#x20;**&#x49;t handles requests and runs JavaScript in pages when needed. It offers simple tools for proxy rotation, which helps prevent IP blocking.

The combined support for web scraping and browser automation makes it **more versatile than tools that cover only one method.**

## How to Install Crawlee

Installing Crawlee is **a straightforward process and only takes a few minutes&#x20;**&#x69;f you already have Node.js set up. If you don’t, download it from [Node.js website ](https://nodejs.org/en). After that, follow these steps.

### 1. Initialize a New Node.js Project

If you’re starting a new project, run:

```javascript
mkdir my-crawlee-project
cd my-crawlee-project
npm init -y
```

This sets up a basic *package.json* file for dependency management.

If using an IDE such as Visual Studio Code, simply **create a new folder and make it your project directory.**

### 2. Install Crawlee Via npm

Now, **install Crawlee&#x20;**&#x75;sing the following command:

```javascript
npm install crawlee
```

This command downloads Crawlee and **adds it to your project’s dependencies.**

Make sure to also create a file in your project directory named *crawler.js.*

### 3. Verifying the Installation

Once installed, you can **verify everything is working&#x20;**&#x62;y creating a basic script like this:

```js
// crawler.js
import { CheerioCrawler } from 'crawlee';

const crawler = new CheerioCrawler({
  async requestHandler({ request, $, log }) {
    log.info(`Crawling: ${request.url}`);
    const title = $('title').text();
    console.log(`Title of ${request.url}: ${title}`);
  },
});

await crawler.run(['https://example.com']);
```

Run it using:

```javascript
node crawler.js
```

If you get an error, create (or edit) the *package.json* file to:

```json
{
  "type": "module",
  "dependencies": {
    "crawlee": "^3.13.9"
  }
}
```

## Basic Structure of a Crawlee Scraper

### 1. Crawler Setup

You can choose between two main types:

- **HTTP-based crawling.&#x20;**&#x55;ses lightweight requests, is fast and simple.
- **Browser-based crawling.&#x20;**&#x4C;oads pages more like a real browser, great for web scraping and browser pages that use JavaScript.

For simple pages, HTTP is faster. But when pages rely on JavaScript, use a headless (or even a headful) browser. **You can pick based on what the website needs.**

### 2. Handling Requests and Responses

The request handler is where you write what happens when the crawler visits a page. You’re basically giving instructions. This part handles each page one at a time and **lets you control how links are followed or retried.**

### 3. Extracting Data from Web Pages

Inside the request handler, you **use [tools like Cheerio ](https://iproyal.com/blog/web-scraping-cheerio-nodejs/)to extract text, links, images, or anything else.&#x20;**&#x46;or web scraping and browser automation, that’s the most important part. Your tools read the pages and pick out what’s needed. Then, you can store the data in JSON or CSV.

Here is a simple example of **what the project script could look like&#x20;**&#x75;sing HTTP crawling:

```js
import { CheerioCrawler } from 'crawlee';


(async () => {
  const crawler = new CheerioCrawler({
    async requestHandler({ $, request }) {
      console.log(`Scraping: ${request.url}`);
      const titles = [];
      $('h2.article-title').each((index, el) => {
        titles.push($(el).text());
      });
      console.log(titles);
    },
  });

  await crawler.run(['https://example-blog.com']);
})();
```

What the script does is this:

- Uses *CheerioCrawler* for HTTP-based crawling.
- Visits each URL and grabs all `<h2>` elements with classes *article-title.*
- Logs the titles to the console.

Web scraping can be quite simple when using Crawlee. **Just make sure you tailor it to your specific project&#x20;**&#x61;nd you’re good to go.

## Simple Web Scraping Example Using Crawlee

Here’s a basic example to help you get started with web scraping using Crawlee. The code below will scrape the titles of blog posts from a website of your choosing. **It’s simple, clear, and easy to copy for your own projects.**

First, make sure you’ve already run this:

```javascript
npm install crawlee
```

Then, create a file named *scrape.js* and add the following code:

```js
import { CheerioCrawler } from 'crawlee';

const crawler = new CheerioCrawler({
  async requestHandler({ request, $ }) {
    console.log(`Visiting: ${request.url}`);

    const titles = [];

    // Adjust the selector if needed
    $('h2.post-title, h2.entry-title, h2.tp-headline-s').each((_, el) => {
      const title = $(el).text().trim();
      if (title) titles.push(title);
    });

    console.log('Captured titles:', titles);
  },
});

await crawler.run(['https://iproyal.com/blog/']);
;
```

Let’s break it down. The code:

- Uses CheerioCrawler for fast HTTP requests.
- Goes to the start URL and grabs all *h2 classes* of *h2.post-title, h2.entry-title, h2.tp-headline-s > text\`.*
- Logs each title to the console.
- Follows the **‘Next Page’&#x20;**&#x6C;ink if one is found.

## Managing Proxies in Crawlee

When performing web scraping on a small scale, one IP address might be enough. However, **if you’re collecting data from multiple pages or websites, you’ll likely encounter blocks.**

Websites can detect lots of traffic from one IP and block or slow you down. **Proxies can help as you can use them to rotate IPs automatically.**

```js
import { CheerioCrawler } from 'crawlee';

import { CheerioCrawler, ProxyConfiguration } from 'crawlee';

const proxyConfig = new ProxyConfiguration({
  proxyUrls: [
    'http://user:pass@proxy1.example.com:8000',
    'http://proxy2.example.com:8000',
  ],
});

const crawler = new CheerioCrawler({
  proxyConfiguration: proxyConfig,
  async requestHandler({ request, response }) {
    console.log(`URL: ${request.url} - Status: ${response.statusCode}`);
  },
});

await crawler.run(['https://iproyal.com']);
```

This kind of setup **allows you to scrape more safely and reliably at scale.&#x20;**&#x57;ith Crawlee, you don’t need to manage the proxy logic all by yourself - it handles that behind the scenes.

## Conclusion

Now you know how to install Crawlee, set up a basic web scraping and browser automation script, and add proxy rotation.

Crawlee handles both headless browsers and HTTP modes, includes JavaScript execution, and simplifies management of requests and proxies.

If you’d like to learn more, check out our guides on [free web crawling tools ](https://iproyal.com/blog/free-web-crawling-tools/)and [scraping with Python ](https://iproyal.com/blog/web-crawling-with-python/).

[Create Account](https://dashboard.iproyal.com/)

[Author](https://iproyal.com/blog/authors/vilius-dumcius/)

[Vilius Dumcius](https://iproyal.com/blog/authors/vilius-dumcius/)

[Head of Engineering](https://iproyal.com/blog/authors/vilius-dumcius/)

With six years of programming experience, Vilius specializes in full-stack web development with PHP (Laravel), MySQL, Docker, Vue.js, and Typescript. Managing a skilled team at IPRoyal for years, he excels in overseeing diverse web projects and custom solutions. Vilius plays a critical role in managing proxy-related tasks for the company, serving as the lead programmer involved in every aspect of the business. Outside of his professional duties, Vilius channels his passion for personal and professional growth, balancing his tech expertise with a commitment to continuous improvement.

[Learn More About Vilius Dumcius ](https://iproyal.com/blog/authors/vilius-dumcius/)[Meet all Writers](https://iproyal.com/blog/authors/)

Share on

### In This Article

- [What Is Crawlee?](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#What-Is-Crawlee)
- [Key Features of Crawlee](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#Key-Features-of-Crawlee)
- [Why Use Crawlee for Web Scraping](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#Why-Use-Crawlee-for-Web-Scraping)
- [How to Install Crawlee](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#How-to-Install-Crawlee)
- [Basic Structure of a Crawlee Scraper](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#Basic-Structure-of-a-Crawlee-Scraper)
- [Simple Web Scraping Example Using Crawlee](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#Simple-Web-Scraping-Example-Using-Crawlee)
- [Managing Proxies in Crawlee](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#Managing-Proxies-in-Crawlee)
- [Conclusion](https://iproyal.com/blog/crawlee-web-scraping-tutorial/#Conclusion)

Ready to get started?

[Register now](https://dashboard.iproyal.com/register/)

Data News in Your Inbox

No spam whatsoever, just pure data gathering news, trending topics and useful links. Unsubscribe anytime.

No spam. Unsubscribe anytime.

## Related articles

[View all](https://iproyal.com/blog/category/tutorials/)

[Tutorials](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

## [The Most Common Payment Processing Obstacles and Solutions for SaaS Companies](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[Here are the most common payment processing obstacles SaaS companies face and the solution that helped us focus on growth and our services!](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[August 8, 2022](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[3 min read](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[Tutorials](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

## [Easy Programmatic SEO with WordPress](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[Our fourth and final entry in the pSEO series explains how to combine programmatic SEO with WordPress using plugins or code snippets.](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[March 30, 2023](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[10 min read](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[Tutorials](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

## [API for Dummies — The Coder’s and No-coder’s Guide](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

[Learn API basics with this guide for coders and non-coders. Discover the different components of an API call.](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

[June 1, 2023](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

[11 min read](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)
