Created
March 26, 2023 00:31
-
-
Save reefwing/cb11c87583655821bd0a5089cd7f5955 to your computer and use it in GitHub Desktop.
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
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