Skip to content
Advertisement

How to loop over multiple pages of a website using Scrapy

Hello everybody out there! I have been working with BeautifulSoup for my scraping projects. Currently, I’m learning Scrapy. I have written a code in BeautifulSoup to loop over multiple pages of a single website using for loops. I looped over 10 pages and fetched URLs of blog posts from those pages using the code below. I want to do the same thing in Scrapy but can’t figure out how. Can the same approach (code) be used with scrapy to do the same thing? Here is the BeautifulSoup code:

JavaScript

This piece of code fetched the links from 10 pages of the website. I stored these links (blog posts links) in the list named li outside the for loop. Then with another for loop on that finalList I wrote my code to extract the text from blog posts.

Advertisement

Answer

JavaScript

Output:

JavaScript
Advertisement