1
resposta

Erro ao ler as tabelas da página https://www.federalreserve.gov/releases/h3/current/default.htm

Tentei ler as tabelas através da url https://www.federalreserve.gov/releases/h3/current/default.htm , entretanto mesmo efetuando os códigos anbaixo:

df_html = pd.read_html('https://www.federalreserve.gov/releases/h3/current/default.htm') df_html[0]

Surgiram estes erros:


HTTPError Traceback (most recent call last) in ----> 1 df_html = pd.read_html('https://www.federalreserve.gov/releases/h3/current/default.htm')

~\anaconda3\envs\alura_pandas\lib\site-packages\pandas\util_decorators.py in wrapper(args, **kwargs) 294 ) 295 warnings.warn(msg, FutureWarning, stacklevel=stacklevel) --> 296 return func(args, **kwargs) 297 298 return wrapper

~\anaconda3\envs\alura_pandas\lib\site-packages\pandas\io\html.py in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, thousands, encoding, decimal, converters, na_values, keep_default_na, displayed_only) 1099 na_values=na_values, 1100 keep_default_na=keep_default_na, -> 1101 displayed_only=displayed_only, 1102 )

~\anaconda3\envs\alura_pandas\lib\site-packages\pandas\io\html.py in parse(flavor, io, match, attrs, encoding, displayedonly, **kwargs) 896 897 try: --> 898 tables = p.parse_tables() 899 except ValueError as caught: 900 # if io is an io-like object, check if it's seekable

~\anaconda3\envs\alura_pandas\lib\site-packages\pandas\io\html.py in parse_tables(self) 215 list of parsed (header, body, footer) tuples from tables. 216 """ --> 217 tables = self.parsetables(self.builddoc(), self.match, self.attrs) 218 return (self.parsethead_tbody_tfoot(table) for table in tables) 219

~\anaconda3\envs\alura_pandas\lib\site-packages\pandas\io\html.py in builddoc(self) 734 pass 735 else: --> 736 raise e 737 else: 738 if not hasattr(r, "text_content"):

~\anaconda3\envs\alura_pandas\lib\site-packages\pandas\io\html.py in builddoc(self) 715 try: 716 if is_url(self.io): --> 717 with urlopen(self.io) as f: 718 r = parse(f, parser=parser) 719 else:

~\anaconda3\envs\alura_pandas\lib\site-packages\pandas\io\common.py in urlopen(args, **kwargs) 135 import urllib.request 136 --> 137 return urllib.request.urlopen(args, **kwargs) 138 139

~\anaconda3\envs\alura_pandas\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 221 else: 222 opener = opener --> 223 return opener.open(url, data, timeout) 224 225 def installopener(opener):

~\anaconda3\envs\alura_pandas\lib\urllib\request.py in open(self, fullurl, data, timeout) 530 for processor in self.process_response.get(protocol, []): 531 meth = getattr(processor, meth_name) --> 532 response = meth(req, response) 533 534 return response

~\anaconda3\envs\alura_pandas\lib\urllib\request.py in http_response(self, request, response) 640 if not (200 <= code < 300): 641 response = self.parent.error( --> 642 'http', request, response, code, msg, hdrs) 643 644 return response

~\anaconda3\envs\alura_pandas\lib\urllib\request.py in error(self, proto, args) 568 if http_err: 569 args = (dict, 'default', 'http_error_default') + orig_args --> 570 return self.callchain(args) 571 572 # XXX probably also want an abstract factory that knows when it makes

~\anaconda3\envs\alura_pandas\lib\urllib\request.py in callchain(self, chain, kind, meth_name, args) 502 for handler in handlers: 503 func = getattr(handler, meth_name) --> 504 result = func(args) 505 if result is not None: 506 return result

~\anaconda3\envs\alura_pandas\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs) 648 class HTTPDefaultErrorHandler(BaseHandler): 649 def http_error_default(self, req, fp, code, msg, hdrs): --> 650 raise HTTPError(req.full_url, code, msg, hdrs, fp) 651 652 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 403: Forbidden

1 resposta

Oi, Ricardo! Tudo bem com você?

Temos um tópico similar no fórum no qual o instrutor soluciona esse problema: Erro ao ler uma página html.

Você pode acessá-lo e seguir os passos mostrados pelo instrutor, caso o problema persista você pode me comunicar aqui, que estarei à disposição para ajudá-lo ;-)

Bons estudos!