Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- url = 'https://quotes.toscrape.com/'
- response = requests.get(url)
- soup = BeautifulSoup(response.content, 'html.parser')
- quotes = soup.find_all('div', {'class': 'quote'})
- for quote in quotes:
- text = quote.find('span', {'class': 'text'}).text
- author = quote.find('small', {'class': 'author'}).text
- print(text)
- print(author)
- tags = quote.find_next_sibling('a', limit=4)
- for tag in tags:
- print(tag)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement