Я пытаюсь удалить список тикеров акций, которые отображаются в таблице по следующей ссылке: http://www.advfn.com/nyse/newyorkstockexchange.asp?companies=A Я удалил таблицу с помощью красивого супа, но когда я преобразовал ее в Фрейм данных Pandas, я получил ошибку: TypeError: Объект 'NoneType' не может быть вызван
Я пробовал следующий код:
url = 'http://www.advfn.com/nyse/newyorkstockexchange.asp?companies=A'
res = requests.get(url)
soup = BeautifulSoup(res.content,'lxml')
table = soup.find("table",{"class":"market tab1"})
df = pd.read_html(table)
, но он не работает, как решить, как это решить?и почему я получаю ошибку?
полный журнал ошибок:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/pandas/io/html.py in _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs)
796 try:
--> 797 tables = p.parse_tables()
798 except Exception as caught:
~/anaconda3/lib/python3.7/site-packages/pandas/io/html.py in parse_tables(self)
212 def parse_tables(self):
--> 213 tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
214 return (self._build_table(table) for table in tables)
~/anaconda3/lib/python3.7/site-packages/pandas/io/html.py in _build_doc(self)
618 # try to parse the input in the simplest way
--> 619 r = parse(self.io, parser=parser)
620 try:
~/anaconda3/lib/python3.7/site-packages/lxml/html/__init__.py in parse(filename_or_url, parser, base_url, **kw)
939 parser = html_parser
--> 940 return etree.parse(filename_or_url, parser, base_url=base_url, **kw)
941
src/lxml/etree.pyx in lxml.etree.parse()
src/lxml/parser.pxi in lxml.etree._parseDocument()
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-23-c3e05c494f63> in <module>
5 table = soup.find("table",{"class":"market tab1"})
6 #print(table)
----> 7 df = pd.read_html(table)
~/anaconda3/lib/python3.7/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, displayed_only)
985 decimal=decimal, converters=converters, na_values=na_values,
986 keep_default_na=keep_default_na,
--> 987 displayed_only=displayed_only)
~/anaconda3/lib/python3.7/site-packages/pandas/io/html.py in _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs)
799 # if `io` is an io-like object, check if it's seekable
800 # and try to rewind it before trying the next parser
--> 801 if hasattr(io, 'seekable') and io.seekable():
802 io.seek(0)
803 elif hasattr(io, 'seekable') and not io.seekable():
TypeError: 'NoneType' object is not callable
начало таблицы:
<table cellpadding="0" cellspacing="1" class="market tab1" width="610">
<colgroup><col/><col/><col class="c"/></colgroup>
<tr><td class="tabh" colspan="3"><b>Companies listed on the NYSE</b></td></tr>
<tr><th>Equity</th><th>Symbol</th><th>Info</th></tr>
<tr class="ts0"><td align="left"><a href="http://ih.advfn.com/stock-market/NYSE/a-k-steel-AKS/stock-price">A K Steel</a></td><td><a href="http://ih.advfn.com/stock-market/NYSE/a-k-steel-AKS/stock-price">AKS</a></td><td><a href="http://ih.advfn.com/stock-market/NYSE/a-k-steel-AKS/chart"><img src="/s/stock-chart.gif"/></a><a href="http://ih.advfn.com/stock-market/NYSE/a-k-steel-AKS/news"><img src="/s/stock-news.gif"/></a><a href="http://ih.advfn.com/stock-market/NYSE/a-k-steel-AKS/financials"><img src="/s/fundamentals.gif"/></a><a href="http://ih.advfn.com/stock-market/NYSE/a-k-steel-AKS/trades"><img src="/s/stock-trades.gif"/></a></td></tr>