Как получить 5 котировок со страницы? Bs4

вот мой сценарий:

@shared_task()
def parser():
    flag = True
    url = 'https://quotes.toscrape.com'
    suffix = ''
    while flag:
        responce = requests.get(url + suffix)
        soup = BeautifulSoup(responce.text, 'html.parser')
        quote_l = soup.find_all('span', {'class': 'text'})
        q_count = 0
        for i in range(len(quote_l)):
            if q_count >= 5:
                flag = False
                break
            quote = soup.find_all('span', {'class': 'text'})[i]
            if not Quote.objects.filter(quote=quote.string).exists():
                author = soup.find_all('small', {'class': 'author'})[i]
                if not Author.objects.filter(name=author.string).exists():
                    a = Author.objects.create(name=author.string)
                    Quote.objects.create(quote=quote.string, author_id=a.id)
                    q_count += 1
                else:
                    a = Author.objects.get(name=author.string)
                    Quote.objects.create(quote=quote.string, author_id=a.id)
                    q_count += 1

        next_page = soup.find('li', {'class': 'next'})
        if not next_page:
            flag = False
            break
        suffix = next_page.a['href']

Мне нужно получить 5 новых кавычек за один запуск программы, но я получаю 5 только на первом запуске, а на остальных 10.Пробовал менять вложенность ничего не помогло.Что посоветуете?

Вернуться на верх