def get_num_pages(page_souped):
    """
        This gets the number of pages to search through.
    :param page_souped: <class 'bs4.BeautifulSoup'>, a page that has been passed through BeautifulSoup().
    :return: int, the number of pages to search through
    """

    span_parsed = page_souped.find_all(lambda tag: tag.name == 'span' and tag.get('class') == ['pageRange'])
    try:
        span_parsed_contents_list = span_parsed[0].contents[0].split(' ')
    except IndexError:
        return 0
    return int(span_parsed_contents_list[-1])