Member-only story
ScrapingPython Running Scrapy In Celery Tasks
Melvin Koh
6 min readMay 17, 2021
A practical, production-ready solution for running scrapers as Celery tasks
Press enter or click to view image in full size Photo by Nicolas Picard on Unsplash
Some time ago, I accepted a project to build a portal for commercial users to scrape product details by submitting links to the product listings. The portal was a site built entirely with Python, and Scrapy.
As scraping pages typically takes time, it is often best to run them in the background and keep the users notified of its progress from time to time.
If you’re reading this, chances are, you are already familiar with Scrapy and/or Celery. In case you’re new to Scrapy, it is an open-source framework for us to write scrapers to extract structured data from websites.
Celery, in short, is a commonly-used, well-supported, distributed task queue in Python that allows us to run long-running tasks in the background by a pool of dedicated workers.…