May 25th, 2020
What's the difference between Scrapy, BeautifulSoup, and Selenium

We are just writing a scraper for one of our internal projects at Proxies API that needs to scrape a bunch of websites in a distributed fashion quickly.

We are using Scrapy for that as the main framework.

We use beautiful soup as a part of that operation to clean up the HTML, get us keywords and meta tags so we can summarize the article using NLTK.

This should give enough perspective. Scrapy is a much larger system that helps you crawl, scrape, and manage data in various ways. Beautiful soup cannot crawl data. It can take your existing data and allow you to query it in various ways. For example, you can use CSS selectors to get at a particular piece of the HTML like a tag for article headlines. But then, Scrapy has inbuilt support for both CSS selectors and XPATH.

Selenium is used when you need to get to dynamically generated data (using AJAX).

Scrapy, by default, doesn't do that, but it can use various external tools like Selenium as middlewares to get dynamic data. Here is an example of you can “paginate” on eBay using Scrapy and Selenium together.

import scrapy
from selenium import webdriver

class ProductSpider(scrapy.Spider):
    name = "product_spider"
    allowed_domains = ['']
    start_urls = ['']

    def __init__(self):
        self.driver = webdriver.Firefox()

    def parse(self, response):

        while True:
            next = self.driver.find_element_by_xpath('//td[@class="pagn-next"]/a')

Share this article:

Get our articles in your inbox

Dont miss our best tips/tricks/tutorials about Web Scraping
Only great content, we don’t share your email with third parties.