import requests, bs4, urllib.parse def process(url): page = requests.get(url) soup = bs4.BeautifulSoup(page.text, 'html5lib') quotes = [] for quote in soup.select('div[class="quote"] > span[class="text"]'): quotes.append(quote.getText()) next_button = soup.select('li[class="next"] > a') if next_button != []: next_url = urllib.parse.urljoin(page.url, next_button[0]['href']) else: next_url = None return quotes, next_url process('http://quotes.toscrape.com/page/1/')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)