from bs4 import BeautifulSoup
import re


def get_sresults_pages_info(page_body):
    """
    Get pagination info (next page and last page number)
    from passed search results page
    """
    soup = BeautifulSoup(page_body, 'html.parser')
    pagination_container = soup.find_all('div', class_='stronnicowanie')

    if not pagination_container:
        raise Exception('no pagination found!')

    pagination_str = pagination_container[0].text
    pages = re.findall(r'\d+', pagination_str)

    pages = [int(p) for p in pages]
    pages[0] += 1

    return pages