Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Created July 11, 2020 14:16
Show Gist options
  • Save Abhayparashar31/689dcbac67afbab310fe19c87f3eab75 to your computer and use it in GitHub Desktop.
Save Abhayparashar31/689dcbac67afbab310fe19c87f3eab75 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import requests
def scrape(url):
res = requests.get(url)
print("\nSearching in Goodreads......")
soup = BeautifulSoup(res.text,'html.parser')
quote = soup.select('.quoteText')
length = len(quote)
for i in range(0,length):
quote = soup.select('.quoteText')[i].getText().strip()
quote = quote.replace("―","Author:")
quote = quote.replace("\n","")
print("\n"+quote)
for i in range(0,5):
url = f'https://www.goodreads.com/quotes?page={i}'
scrape(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment