Skip to content

Instantly share code, notes, and snippets.

@T31337
Created September 10, 2023 05:19
Show Gist options
  • Save T31337/f0b447f936df7b8ad3b6d9312afb2c13 to your computer and use it in GitHub Desktop.
Save T31337/f0b447f936df7b8ad3b6d9312afb2c13 to your computer and use it in GitHub Desktop.
Quote Scraper
#Scrape quotes using requests and BeautifulSoup4
import requests
from bs4 import BeautifulSoup
urls = ["http://qoutes.toscrape.com", "http://quotes.toscrape.com/tag/love/", "http://quotes.toscrape.com/tag/inspirational/", "http://quotes.toscrape.com/tag/humor/"]
for page in urls:
html = requests.get(page)
soup = BeautifulSoup(html.text, "html.parser")
quotes = soup.find_all("span",class_="text")
authors = soup.find_all("small",class_="author")
for quote, author in zip(quotes, authors):
print(f"{quote.text}\n{author.text}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment