blob: 19a51faf018c0a9658d257b301a696c150867ad6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from bs4 import BeautifulSoup, Tag
import httpx as h
from tabulate import tabulate
r = h.get('https://www.naqt.com/stats/school/players.jsp?org_id=69304')
html = BeautifulSoup(r.text, 'lxml')
tbl = html.find('section', attrs={'id': 'players'}).table
headers = [e.text for e in tbl.thead.tr.find_all('th')]
data = []
elem: Tag
for elem in tbl.tbody.find_all('tr'):
temp = []
for z in elem.find_all():
temp.append(z.text)
data.append(temp[1:])
print(tabulate(data, headers, showindex=False))
|