作为一个菜鸟,我刚开始使用datareader库,尤其是read_html函数,并在尝试从网站获取表时遇到以下错误。
import pandas as pd
from pandas_datareader import data
df_list=pd.read_html('https://www.mismarcadores.com/futbol/espana/laliga/clasificacion/')
print(len(df_list))
然后我通过提高(第346行)出现此语法错误
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-44-c546df3e8ebd> in <module>()
----> 1 df_list=pd.read_html('https://www.mismarcadores.com/futbol/espana/laliga/clasificacion/')
2 print(len(df_list))
~\Anaconda3\lib\site-packages\pandas\io\html.py in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, tupleize_cols, thousands, encoding, decimal, converters, na_values, keep_default_na)
904 thousands=thousands, attrs=attrs, encoding=encoding,
905 decimal=decimal, converters=converters, na_values=na_values,
--> 906 keep_default_na=keep_default_na)
~\Anaconda3\lib\site-packages\pandas\io\html.py in _parse(flavor, io, match, attrs, encoding, **kwargs)
741 break
742 else:
--> 743 raise_with_traceback(retained)
744
745 ret = []
~\Anaconda3\lib\site-packages\pandas\compat\__init__.py in raise_with_traceback(exc, traceback)
342 if traceback == Ellipsis:
343 _, _, traceback = sys.exc_info()
--> 344 raise exc.with_traceback(traceback)
345 else:
346 # this version of raise is a syntax error in Python 3
ValueError: No tables found
检查HTML代码时,该url上实际上有一个表格标签,我不明白为什么它没有将其选中...
非常感谢您的帮助。