Pessoal, não estou conseguindo resolver isso:
in: df_html = pd.read_html('https://www.federalreserve.gov/releases/h3/current/default.htm') df_html[0]
out: ---------------------------------------------------------------------------HTTPError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel9388\878446073.py in ----> 1 dfhtml = pd.readhtml('https://www.federalreserve.gov/releases/h3/current/default.htm') 2 dfhtml[0]
~\anaconda3\lib\site-packages\pandas\util\decorators.py in wrapper(args, kwargs) 309 stacklevel=stacklevel, 310 ) --> 311 return func(args, kwargs) 312 313 return wrapper
~\anaconda3\lib\site-packages\pandas\io\html.py in readhtml(io, match, flavor, header, indexcol, skiprows, attrs, parsedates, thousands, encoding, decimal, converters, navalues, keepdefaultna, displayedonly) 1111 io = stringifypath(io) 1112 -> 1113 return parse( 1114 flavor=flavor, 1115 io=io,
~\anaconda3\lib\site-packages\pandas\io\html.py in parse(flavor, io, match, attrs, encoding, displayedonly, kwargs)
917
918 try:
--> 919 tables = p.parsetables()
920 except ValueError as caught:
921 # if io
is an io-like object, check if it's seekable
~\anaconda3\lib\site-packages\pandas\io\html.py in parsetables(self) 237 list of parsed (header, body, footer) tuples from tables. 238 """ --> 239 tables = self.parsetables(self.builddoc(), self.match, self.attrs) 240 return (self.parsetheadtbodytfoot(table) for table in tables) 241
~\anaconda3\lib\site-packages\pandas\io\html.py in builddoc(self) 756 pass 757 else: --> 758 raise e 759 else: 760 if not hasattr(r, "textcontent"):
~\anaconda3\lib\site-packages\pandas\io\html.py in builddoc(self) 737 try: 738 if isurl(self.io): --> 739 with urlopen(self.io) as f: 740 r = parse(f, parser=parser) 741 else:
~\anaconda3\lib\site-packages\pandas\io\common.py in urlopen(args, kwargs) 234 import urllib.request 235 --> 236 return urllib.request.urlopen(args, kwargs) 237 238
~\anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 212 else: 213 opener = opener --> 214 return opener.open(url, data, timeout) 215 216 def installopener(opener):
~\anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 521 for processor in self.processresponse.get(protocol, []): 522 meth = getattr(processor, methname) --> 523 response = meth(req, response) 524 525 return response
~\anaconda3\lib\urllib\request.py in httpresponse(self, request, response) 630 # request was successfully received, understood, and accepted. 631 if not (200 <= code < 300): --> 632 response = self.parent.error( 633 'http', request, response, code, msg, hdrs) 634
~\anaconda3\lib\urllib\request.py in error(self, proto, args) 559 if httperr: 560 args = (dict, 'default', 'httperrordefault') + origargs --> 561 return self.callchain(args) 562 563 # XXX probably also want an abstract factory that knows when it makes
~\anaconda3\lib\urllib\request.py in callchain(self, chain, kind, methname, args) 492 for handler in handlers: 493 func = getattr(handler, methname) --> 494 result = func(args) 495 if result is not None: 496 return result
~\anaconda3\lib\urllib\request.py in httperrordefault(self, req, fp, code, msg, hdrs) 639 class HTTPDefaultErrorHandler(BaseHandler): 640 def httperrordefault(self, req, fp, code, msg, hdrs): --> 641 raise HTTPError(req.fullurl, code, msg, hdrs, fp) 642 643 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 403: Forbidden
Alguém consegue me ajudar?
Fiz as seguintes instalações:
- pip install requests
- pip install bs4
- pip install html5lib
dados: https://www.federalreserve.gov/releases/h3/current/default.htm