如何使用BeautifulSoup、Requests和Python从HTML中的特定表中提取数据?

如何使用BeautifulSoup、Requests和Python从HTML中的特定表中提取数据?,python,web-scraping,beautifulsoup,python-requests,Python,Web Scraping,Beautifulsoup,Python Requests,以下是我目前拥有的代码: from bs4 import BeautifulSoup import requests url = requests.get("http://eiupanthers.com/boxscore.aspx?path=baseball&id=5065").content soup = BeautifulSoup(url, 'html.parser') table = soup.find('table', {'class': 'sidearm-table

以下是我目前拥有的代码:

from bs4 import BeautifulSoup

import requests

url  = requests.get("http://eiupanthers.com/boxscore.aspx?path=baseball&id=5065").content

soup = BeautifulSoup(url, 'html.parser')

table = soup.find('table', {'class': 'sidearm-table play-by-play'})
我的表变量不断返回空值(或“无”)。这可能只是一个语法问题。我非常精通Matlab,但是我对Python/BeautifulSoup/Requests/等还是相当陌生的

任何指点都将不胜感激

我主要尝试从逐场播放表中提取数据,以便在替代程序中解析这些数据,并为单个玩家组装数据结构。这一部分我很有信心,一旦我收集了数据,我就能完成

谢谢你的帮助

from bs4 import BeautifulSoup

import requests

header = {'User-agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5'}

url = requests.get("http://eiupanthers.com/boxscore.aspx?path=baseball&id=5065", headers=header).text

soup = BeautifulSoup(url, 'html.parser')
table = soup.find('table', {'class': 'sidearm-table play-by-play'})

print(table)

问题似乎是网站需要某种类型的标题,即使
请求
模块有很好的支持,您也必须通过上面提到的类似支持。

对不起,我已经回答了这个问题。我认为问题在于
.content
不能正常工作,但我错了。该网站只是需要某种身份验证。