Search⌘ K
AI Features

Scrapy

Understand how to employ Scrapy, a powerful Python framework for web scraping, to systematically extract data such as questions, votes, views, and answers from websites by using CSS selectors and real-world examples.

Scrapy

Scrapy is one of the other tools that we can use to extract data from sites. It has a more organized structure and works in a systematic manner. We won’t go into too much detail, though. Instead, we will look at a real-time example of scraping data using Scrapy to understand how it works.

Exercise

We will visit a site that displays questions/queries asked by people all over the world. A screenshot of the image is shown below:

We will scrape the top ten questions available at the time the site is accessed by our code. Each scraped item will include four components of a question:

  1. Summary
  2. Votes
  3. Views
  4. Number of answers

Single question’s HTML

Go to the site and pick one question.

...