【发布时间】:2021-12-02 11:46:32
【问题描述】:
我想从这个网站获取一个名为 Form table (last 8) https://www.soccerstats.com/pmatch.asp?league=italy&stats=145-7-5-2022 的特定表格,但我得到了AttributeError: 'NoneType' object has no attribute 'text'
代码
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36'}
s = requests.Session()
s.headers.update(headers)
response = requests.get(link, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
standings_forms = soup.find_all('table', border='0', cellspacing='0', cellpadding='0', width='100%')
for t in standings_forms:
if t.find('b').text == 'Form table (last 8)':
print(t)
【问题讨论】:
标签: python web-scraping beautifulsoup