假设我有一个包含 10 列和 100 行的 html 表,我要做的就是使用 Beautifulsoup 在退出时查找数据并打印整行。
import urllib3
from bs4 import BeautifulSou
http = urllib3.PoolManager()
url "https://en.wikipedia.org/wiki/List_of_Asian_countries_by_area"
response = http.request('GET', url)
soup = BeautifulSoup(response.data, "html.parser")
for tr in soup.find_all('tr')[2:]:
tds = tr.find_all('td')
print(tds)