How to scrape multiple pages of a site using tabs with BeautifulSoup?

I’m looking to create a web scraper that scrapes search results from the Ask.com site. However, when I scrape search results from Ask.com after running the following code:






def search(request):
    if request.method == 'POST':
        search = request.POST['search']
        url = 'https://www.ask.com/web?q='+search
        res = requests.get(url)
        soup = bs(res.text, 'lxml')

        result_listings = soup.find_all('div', {'class': 'PartialSearchResults-item'})

        final_result = []

        for result in result_listings:
            result_title = result.find(class_='PartialSearchResults-item-title').text
            result_url = result.find('a').get('href')
            result_desc = result.find(class_='PartialSearchResults-item-abstract').text

            final_result.append((result_title, result_url, result_desc))

        context = {
            'final_result': final_result
        }

        

, my scraper is limited to the first page of results and I would like it to follow tabs in order to scrape other pages of search results, so I modified the code above:



def search(request):
    if request.method == 'POST':
        search = request.POST['search']
        url = 'https://www.ask.com/web?q='+search
        res = requests.get(url)
        soup = bs(res.text, 'lxml')

        result_listings = soup.find_all('div', {'class': 'PartialSearchResults-item'})

        final_result = []

        for result in result_listings:
            result_title = result.find(class_='PartialSearchResults-item-title').text
            result_url = result.find('a').get('href')
            result_desc = result.find(class_='PartialSearchResults-item-abstract').text

            next_page = result.find('a').get('PartialWebPagination-next ')
            if next_page:
                url = next_page.attrib.get('href')
                return requests.get(url)
            final_result.append((result_title, result_url, result_desc))

        context = {
            'final_result': final_result
        }

       

Unfortunately, my scraper works as it did at the beginning and is limited to the first page of search results. Being a beginner in BeautifulSoup, I ask for help from the community. Thank you for reading my question, I look forward to your answers.