]> git.armaanb.net Git - phrases.git/blob - extract.py
first push
[phrases.git] / extract.py
1 #!/usr/bin/env python3
2 # Tool to extract famous phrases from wikipedia
3 from bs4 import BeautifulSoup
4 import requests
5
6 url = 'https://en.wikipedia.org/wiki/List_of_Latin_phrases_(full)'
7 response = requests.get(url)
8 html = response.content
9
10 soup = BeautifulSoup(html, "html.parser")
11 list_table = soup.find_all("table", attrs={"class":"wikitable"})
12
13 output = []
14
15 for table in list_table:
16     for row in table.find_all("tr")[1:]:
17         cell = row.find_all("td")
18         for content in cell:
19             text = content.get_text()
20             output.append(text)
21
22 print(output)
23