<jupyter_start><jupyter_text><jupyter_code>import requests
from bs4 import BeautifulSoup
def get_quotes(url):
  res = requests.get(url)
  soup = BeautifulSoup(res.text)
  quotes_div = soup.find_all("div",attrs={"class":"quote"})
  quotes=[]
  for quote in quotes_div:
    quotes_text = quote.find_next("div",attrs={"class":"quoteText"})
    striped = quotes_text.text.strip()
    stripedli = striped.split("\n")
    text = stripedli[0] [1:-1]
    author = stripedli[3].strip() [:-2]
    left_divs = quote.find_next("div",attrs={"class":"left"})
    tags = [tag.text for tag in left_divs.find_all("a")]
              
    quote_item = {
          "author":author,
          "quote":text,
          "tags":tags
      }
    quotes.append(quote_item)
  return quotes
url = "https://www.goodreads.com/quotes/tag/{}?page={}"

type = input("Enter the type of quotes you want, say \"Love\" for example: ")
pages = int(input("Enter the number of pages whose quotes you want: "))

total = []
for page in range(1,pages+1):
  data = get_quotes(url.format(type,page))
  total.extend(data)
  print ("processed", page)
  
import pandas as pd
df = pd.DataFrame(total)
df.to_csv("scrap.csv")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1611295681063123, 'fraction_numerical': 0.006644518272425249, 'mean_word_length': 3.8393574297188753, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '158517', 'license': 'Apache-2.0', 'n_tokens_mistral': 430, 'n_tokens_neox': 427, 'n_words': 88, 'path': 'Scrap.ipynb', 'repo_name': 'Snehil-Mittal/Quotes_Extractor', 'size': '1204'}