I am having issue in range 10 because of which all pages are not scraped

Viewed 33
        for i in range(10):
            print("Date: ", date_list[i])
            print("Title: ", title_list[i])
            # print("Description: ", description_list[i])
            print()

       

This is the news scraper of business recorder and the problem is that as I have given range 10 but in the website, few pages have different size of news in the pages such as 10, 20, 4, 15, 2 news in a page.

How can I make a code that can scrape all the news that are in a certain page?

1 Answers

How can I make a code that can scrape all the news that are in a certain page?

It seems to me that you are scraping everything, just not necessarily printing everything you're scraping (or possibly trying to print too much).

I think what you're looking for is zip in this case:

for date, title in zip(date_list, title_list):
    print(f"Date: {date}")
    print(f"Title: {title}")
Related