soup.find('ul', {'class': 'pagination'})
will return single element and you cannot iterate over itno tested, but something like
pagination = soup.find('ul', {'class': 'pagination'}) pages = pagination.find_all('li') num_pages = int(pages[-2].text) print(num_pages)if you inspect the ul element you will notice there are 4 types of li items (without class attribute, class=empty, class=next, class=is-active). you can play with custom function that will return just li items without class.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs