Crawling is the heart of any serious web scrapping project. In Scrapy (still the #1 framework for structured crawling in 2026), crawling means systematically following links across pages, handling pagination, respecting depth limits, and extracting data at scale — all while avoiding blocks and staying ethical.
This updated 2026 guide explains how to build robust crawlers with Scrapy 2.14+, including modern async patterns, pagination strategies, CrawlSpider rules, depth control, and best practices to stay under the radar.
What Does "Crawling" Mean in Web Scrapping?
Crawling = discovering and visiting new pages by following hyperlinks. In Scrapy, this happens through:
start_urls+parse()→ manual followingresponse.follow()→ link followingCrawlSpider+Rule→ automatic link extraction & pagination
Option 1: Manual Crawling with Basic Spider (Simple Pagination)
# spiders/news_crawler.py
import scrapy
class NewsCrawler(scrapy.Spider):
name = "news"
start_urls = ["https://example.com/news/page/1"]
def parse(self, response):
# Extract articles on current page
for article in response.css("article.post"):
yield {
"title": article.css("h2::text").get(),
"url": article.css("h2 a::attr(href)").get(),
"date": article.css(".date::text").get()
}
# Follow next page (pagination)
next_page = response.css("a.next::attr(href)").get()
if next_page:
yield response.follow(next_page, callback=self.parse)
Option 2: Automatic Crawling with CrawlSpider + Rules (Recommended 2026)
Use CrawlSpider for automatic link discovery and pagination handling.
# spiders/blog_spider.py
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
class BlogSpider(CrawlSpider):
name = "blog"
allowed_domains = ["example.com"]
start_urls = ["https://example.com/blog/"]
rules = (
# Extract all article links and parse them
Rule(LinkExtractor(allow=r"/blog/article/"), callback="parse_article", follow=True),
# Follow pagination links (common patterns)
Rule(LinkExtractor(allow=r"/page/\d+/", deny=r"/page/1000/"), follow=True),
)
def parse_article(self, response):
yield {
"title": response.css("h1.article-title::text").get(),
"content": response.css("div.content").get(),
"author": response.css(".author::text").get(),
"url": response.url
}
Depth & Performance Control in 2026
Set these in settings.py to prevent infinite crawling:
DEPTH_LIMIT = 5 # max link depth
DEPTH_PRIORITY = 1 # higher depth = lower priority
CONCURRENT_REQUESTS = 8
DOWNLOAD_DELAY = 1.2 # polite delay
RANDOMIZE_DOWNLOAD_DELAY = True
How Pagination Crawling Stops
Pagination is the most common form of crawling: a list spread over pages 1, 2, 3 and so on. The spider reads one page, yields its items, then follows the next-page link. The crawl ends when there is no next link.
Relying only on the next link can go wrong if a site loops back to page 1 or shows an empty page with a next link. Add a second stop condition, such as no items found or a maximum page number, and let Scrapy's duplicate filter drop repeated URLs.
Keep DOWNLOAD_DELAY and ROBOTSTXT_OBEY switched on, since pagination can create many requests quickly.
Worked Example: Following Next Links With Two Stop Rules
We simulate a paginated listing in a dictionary and follow next links until a stop rule fires.
from bs4 import BeautifulSoup
PAGES = {
"/page/1/": '<li>A</li><li>B</li><a class="next" href="/page/2/">Next</a>',
"/page/2/": '<li>C</li><a class="next" href="/page/3/">Next</a>',
"/page/3/": '<a class="next" href="/page/4/">Next</a>',
}
def crawl_pages(url="/page/1/", max_pages=50):
items, visited = [], 0
while url and visited < max_pages:
soup = BeautifulSoup(PAGES.get(url, ""), "html.parser")
visited += 1
found = [li.get_text() for li in soup.select("li")]
if not found:
print("Stopped: empty page", url)
break
items += found
nxt = soup.select_one("a.next")
url = nxt["href"] if nxt else None
return items
print(crawl_pages())
The crawler collects A, B and C. Page 3 has a next link but no items, so the empty-page rule stops the crawl there instead of requesting page 4.
Practical Tips
Log the page number and item count for each page. A page with far fewer items than usual often signals a layout change or a block, and the log helps you find it quickly.
Common Mistakes
- Trusting the next link as the only stop condition.
- Building page URLs by counting without checking the real last page.
- Turning off the duplicate filter.
- Crawling pagination without any delay.
Quick Summary
- Follow next links page by page.
- Stop on empty pages or a page limit.
- Let the duplicate filter drop repeats.
- Keep delays and robots rules on.
2026 Best Practices for Reliable Crawling
- Use async def parse() when possible (Scrapy 2.13+)
- Integrate scrapy-playwright for JavaScript-rendered pagination
- Rotate User-Agents & headers via
scrapy-user-agentsmiddleware - Enable
ROBOTSTXT_OBEY = Trueby default - Add realistic delays & concurrent request limits
- Save output incrementally:
scrapy crawl blog -o data.jl -s FEED_EXPORT_ENCODING=utf-8
Ethical & Legal Reminders for Crawling
Always respect robots.txt, avoid aggressive crawling, and prefer official APIs when available. High-volume crawling of protected sites can lead to IP bans or legal notices.
Last updated: March 19, 2026 – Scrapy 2.14 brings better coroutine support and improved link extractors, making crawling more efficient and reliable than ever.