Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Scrape the number of pages in a book from
# Add links to urllist for more pages.
# Code can be expanded to scrape more.
import requests
from bs4 import BeautifulSoup
urllist = [
for url in urllist:
r = requests.get(url)
soup = BeautifulSoup(r.text)
tmp = ''
for line in soup.get_text().split():
if line.lower() == 'pages' and tmp.isdigit():
print tmp,line, ' - ',soup.html.head.title.text
tmp = line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment