Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Coursera

Web Scraping Tutorial with Scrapy and Python for Beginners

Packt via Coursera

Overview

In this course, you'll start by learning the fundamentals of web scraping, including what it is and how it works. You'll be introduced to Scrapy, one of the most powerful and widely-used Python frameworks for web scraping, and get hands-on experience setting it up on various operating systems. As you progress, you'll dive into core Scrapy components like Spiders, Selectors, and the Scrapy Shell, which are essential for navigating and extracting data from websites. The course then delves into more advanced topics such as using CSS and XPath selectors to pinpoint and extract specific elements from web pages. You'll also learn how to handle dynamic websites that rely on JavaScript for content rendering by integrating Scrapy with Playwright. Comprehensive modules on working with Scrapy Items, Pipelines, and exporting data will ensure you can store the extracted data efficiently in various formats such as JSON, CSV, and databases like MongoDB. To solidify your learning, you'll undertake multiple projects, such as scraping data from ESPN's Champions League table and Amazon product rankings. These projects will enable you to apply your skills to real-world scenarios, preparing you to handle complex scraping challenges. By the end of the course, you’ll have the confidence and technical know-how to create robust web scrapers that can automate data extraction processes for various applications. This course is designed for Python beginners and intermediate programmers interested in automating data extraction from websites. No prior experience with Scrapy is required, but basic Python knowledge is recommended. Ideal for data enthusiasts, analysts, and developers who want to expand their skill set in web scraping.

Syllabus

  • Introduction to the Course
    • In this module, we will introduce you to the fundamental concept of web scraping, how it works, and how the Scrapy framework can help extract data from websites. You’ll gain a clear understanding of the basic terminology and workflow involved in this process.
  • Scrapy Installation
    • In this module, we will guide you through the installation of Scrapy on both Windows and Ubuntu systems. You'll learn how to create your first Scrapy project and familiarize yourself with its structure through a detailed project walkthrough.
  • Scrapy Spider
    • In this module, we will walk you through the process of creating a Scrapy spider, sending requests, and receiving responses. We will also cover how to use CSS selectors to extract data, giving you the skills to build and refine your spider.
  • CSS Selectors
    • In this module, we will explore the use of CSS selectors to locate web elements efficiently. You’ll learn how to use basic and attribute-based selectors to extract data from web pages, comparing their strengths with XPath.
  • XPath
    • In this module, we will dive into the power of XPath for web scraping. You'll learn how to write XPath expressions, use attribute selectors, and leverage the text() function to extract data efficiently from web elements.
  • Scrapy Shell
    • In this module, we will introduce the Scrapy Shell, a powerful interactive tool for testing and debugging web scraping tasks. You'll practice fetching responses and configuring the shell to fit different scraping scenarios.
  • Scrapy Items
    • In this module, we will focus on using Scrapy items to organize the data you scrape. You'll learn how to define fields, process input and output data, and work with ItemLoaders to simplify the handling of complex data.
  • Exporting Data
    • In this module, we will explore how to export data extracted using Scrapy into various formats like JSON, CSV, and XML. You’ll also learn techniques to overwrite or append data, making the export process more flexible.
  • Scrapy Item Pipeline
    • In this module, we will cover how to use item pipelines to process and store scraped data efficiently. You’ll learn to save data locally or in MongoDB, ensuring that your scraping workflows are scalable and well-organized.
  • Pagination
    • In this module, we will demonstrate how to handle pagination by extracting links from web pages and sending requests to retrieve additional data. You’ll also learn how to automate the process with the start_requests() method.
  • Following Links
    • In this module, we will show you how to follow links in Scrapy spiders, select data using regular expressions, and set up custom callback functions to handle more complex scraping tasks, such as navigating between product pages.
  • Scraping Tables
    • In this module, we will teach you how to scrape data from HTML tables. You will learn the techniques to select table rows, cells, and handle complex table structures to ensure accurate data extraction.
  • Logging into Websites
    • In this module, we will focus on scraping data from websites that require login credentials. You'll learn how to inspect forms, log in using Scrapy's FormRequest, and work with CSRF protection to bypass security restrictions.
  • Scraping JavaScript Rendered Websites
    • In this module, we will explore scraping JavaScript-rendered websites using Scrapy and Playwright. You’ll learn how to install and configure Playwright, render dynamic web pages, and extract data from these types of websites.
  • Scrapy Playwright
    • In this module, we will explore Playwright’s advanced features in combination with Scrapy. You will learn how to handle dynamic websites, including those with infinite scrolling and loading screens, while collecting data.
  • API Endpoints
    • In this module, we will teach you how to identify and interact with API endpoints, enabling you to bypass scraping web pages and directly request structured data from the API for more efficient data collection.
  • Settings
    • In this module, we will cover the settings that affect your entire Scrapy project, including handling robots.txt files, configuring middleware, and optimizing your scraping speed using the Autothrottle extension.
  • User Agents and Proxies
    • In this module, we will explain how to use user agents and proxies to avoid being blocked while scraping. You will learn how to rotate these configurations dynamically to maintain efficient data collection.
  • Tips and Tricks
    • In this module, we will share practical tips and tricks to enhance your scraping experience. You will learn about customizing spiders, running standalone spiders, and advanced methods for extracting and manipulating data.
  • Project 1: Champions League Table from ESPN.com
    • In this project module, we will guide you through scraping sports data from ESPN.com. You will build a Scrapy spider, inspect the website, and extract key information such as teams, rankings, and match details.
  • Project 2: Amazon Product Rank
    • In this project module, we will focus on scraping product rankings from Amazon. You’ll learn how to locate selectors, structure your data, and build a complete spider to automate the extraction process.
  • Project 3: Extending Scraper with GUI
    • In this project module, we will demonstrate how to extend your scraper by building a graphical user interface (GUI). You will learn how to set up the interface and trigger spiders directly from the application.

Taught by

Packt - Course Instructors

Reviews

Start your review of Web Scraping Tutorial with Scrapy and Python for Beginners

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.