1
resposta

Erro ao importa por meio da URL

Não consegui importar por meio do URL

código: df_html = pd.read_html('https://unafiscosaude.org.br/site/tabelas-de-precos-dos-planos-ativos-para-comercializacao/') df_html[0]

lista de erros: OSError Traceback (most recent call last) ~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 1316 h.request(req.get_method(), req.selector, req.data, headers, -> 1317 encode_chunked=req.has_header('Transfer-encoding')) 1318 except OSError as err: # timeout error

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in request(self, method, url, body, headers, encode_chunked) 1228 """Send a complete request to the server.""" -> 1229 self.sendrequest(method, url, body, headers, encode_chunked) 1230

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in sendrequest(self, method, url, body, headers, encode_chunked) 1274 body = encode(body, 'body') -> 1275 self.endheaders(body, encodechunked=encode_chunked) 1276

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in endheaders(self, message_body, encode_chunked) 1223 raise CannotSendHeader() -> 1224 self.sendoutput(message_body, encode_chunked=encode_chunked) 1225

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in sendoutput(self, message_body, encode_chunked) 1015 del self._buffer[:] -> 1016 self.send(msg) 1017

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in send(self, data) 955 if self.auto_open: --> 956 self.connect() 957 else:

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in connect(self) 1383 -> 1384 super().connect() 1385

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in connect(self) 931 if self.tunnelhost: --> 932 self._tunnel() 933

~\AppData\Local\Continuum\anaconda3\lib\http\client.py in _tunnel(self) 910 raise OSError("Tunnel connection failed: %d %s" % (code, --> 911 message.strip())) 912 while True:

OSError: Tunnel connection failed: 407 authenticationrequired

During handling of the above exception, another exception occurred:

URLError Traceback (most recent call last) in ----> 1 df_html = pd.read_html('https://unafiscosaude.org.br/site/tabelas-de-precos-dos-planos-ativos-para-comercializacao/') 2 df_html[0]

~\AppData\Local\Continuum\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, displayed_only) 1092 decimal=decimal, converters=converters, na_values=na_values, 1093 keep_default_na=keep_default_na, -> 1094 displayed_only=displayed_only)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\html.py in parse(flavor, io, match, attrs, encoding, displayedonly, **kwargs) 914 break 915 else: --> 916 raise_with_traceback(retained) 917 918 ret = []

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\compat_init__.py in raisewith_traceback(exc, traceback) 418 if traceback == Ellipsis: 419 , _, traceback = sys.excinfo() --> 420 raise exc.with_traceback(traceback) 421 else: 422 # this version of raise is a syntax error in Python 3

URLError: <urlopen error Tunnel connection failed: 407 authenticationrequired>

1 resposta

Olá Juliana, tudo bem contigo?

Repliquei o exercício no meu computador, achei o mesmo problema e está relacionado com o proxy. Ainda não encontrei a solução, mas estou tentando.

Até mais