Advertisement
Guest User

latinphrases.py

a guest
Jan 18th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. import re
  2. import requests
  3. from bs4 import BeautifulSoup
  4.  
  5. latin_phrases_page = requests.get("https://en.wikipedia.org/wiki/List_of_Latin_phrases_(full)")
  6. latin_phrases_soup = BeautifulSoup(latin_phrases_page.text, "html.parser")
  7. rows = latin_phrases_soup.find_all("tr")
  8. for row in rows:
  9.     cells = row.find_all("td", recursive=False)
  10.     if len(cells) > 0:
  11.         phrase = cells[0].find("b")
  12.         if phrase is not None:
  13.             chars = re.sub(r'[^a-z]+', '', phrase.text)
  14.             words = phrase.text.split(" ")
  15.             if len(chars) == 13 and len(words) == 4:
  16.                 print(phrase.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement