我一直在试图找出如何用python3.6和beauthoulsoup和Pandas模块从Fangraphs获取棒球箱得分。我的最终目标是在Excel中将网页的不同部分保存到不同的工作表中。在
为了做到这一点,我想我必须通过每个表各自的id标签来分别拉动它们。这是为组成第一个excel表的四个表(在页面上的图形下方)执行此操作的代码。运行代码会导致以下错误:
Traceback (most recent call last):
File "Fangraphs Box Score Scraper.py", line 14, in <module>
df1 = pd.read_html(soup,attrs={'id': ['WinsBox1_dghb','WinsBox1_dghp','WinsBox1_dgab','WinsBox1_dgap']})
File "C:\Python36\lib\site-packages\pandas\io\html.py", line 906, in read_html
keep_default_na=keep_default_na)
File "C:\Python36\lib\site-packages\pandas\io\html.py", line 743, in _parse
raise_with_traceback(retained)
File "C:\Python36\lib\site-packages\pandas\compat\__init__.py", line 344, in raise_with_traceback
raise exc.with_traceback(traceback)
TypeError: 'NoneType' object is not callable
你用错了
id
,你采用了<div>
的形式,但需要从<table>
标签read_html attrs开始,我想你不需要使用bs,试试看:相关问题 更多 >
编程相关推荐