-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinguistics.py
More file actions
28 lines (27 loc) · 1.08 KB
/
linguistics.py
File metadata and controls
28 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
import bs4
from bs4 import BeautifulSoup
def linguists():
page = requests.get('https://www.thefamouspeople.com/linguists.php')
soup = BeautifulSoup(page.content, 'html.parser')
text = soup.find_all('div', {"class":'wrapper'})
linguist = []
for count, s in enumerate(text):
if count == 3:
continue
data = {}
name = s.find('a').text
data['Name'] = name
print(name)
for i in range(len(s.find_all('div', {"class":'desc-q'}))):
info = s.find_all('div', {"class":'desc-q'})[i].text
category = info[:info.find(':')]
detail = info[info.find(':') + 2:]
data[category] = detail
# print(len(s.find_all('div', {"class":'desc-q'})))
# nationality = s.find_all('div', {"class":'desc-q'})[0].text
# nationality = nationality[s.find_all('div', {"class":'desc-q'})[1].text.find(':') + 2:]
# print(nationality)
# linguist.append({'name': name, 'nationality': nationality})
linguist.append(data)
return {'linguists': linguist}