Created
September 10, 2023 05:19
-
-
Save T31337/f0b447f936df7b8ad3b6d9312afb2c13 to your computer and use it in GitHub Desktop.
Quote Scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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