Skip to content

Instantly share code, notes, and snippets.

@reefwing
Created March 26, 2023 00:31
Show Gist options
  • Save reefwing/cb11c87583655821bd0a5089cd7f5955 to your computer and use it in GitHub Desktop.
Save reefwing/cb11c87583655821bd0a5089cd7f5955 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
# Send a request to the website and get its content
response = requests.get("http://quotes.toscrape.com")
content = response.content
# Parse the content with BeautifulSoup
soup = BeautifulSoup(content, "html.parser")
# Find the quote and author elements on the page
quote = soup.find("span", class_="text").text
author = soup.find("small", class_="author").text
# Print the quote and author information
print(f"Quote: {quote}")
print(f"Author: {author}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment