Python get and post requests fails with Connection and GetAddrinfo - python

import requests
r = requests.get('http://http2bin.org/get')
I am getting below errors:
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError:
HTTPConnectionPool(host='http2bin.org', port=80): Max retries exceeded
with url: /get (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at
0x031CAB08>: Failed to establish a new connection: [Errno 11004]
getaddrinfo failed'))
What could be the reason? Is it related to Proxy ?

It's a website problem.Try it with another website surely it would work.

Related

Stop displaying this error and print instead just "error"

how to stop displaying this error and print instead just "error":
HTTPConnectionPool(host='domain.com', port=80): Max retries exceeded with url: /api
(Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f21ceed4690>:
Failed to establish a new connection: [Errno -2] Name or service not known',))

Problem using Python client library for Plaid

I'm following the tutorial, but I get an error when I use item_public_token_exchange.
itempublic_tokenexchange
exchange_request = ItemPublicTokenExchangeRequest(
public_token=plaid_token
)
exchange_response = CLIENT.item_public_token_exchange(exchange_request)
the error:
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='sandbox', port=80): Max retries exceeded with url: /item/public_token/exchange (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10f1493a0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
Not sure what is happening.
It looks like the problem is that you are trying to connect to sandbox instead of sandbox.plaid.com. Make sure you have your host set up as plaid.Environment.Sandbox (or, alternatively, sandbox.plaid.com) and not just sandbox.

How to catch exception MaxRetryError?

I have a list of proxy addresses for which I want to connect the telegrams-bot.
Proxies can be blocked over time or simply not work, this can be seen by the MaxRetryError error.
But I can't catch an error. I have an error in logs.
I want to catch an error and switch to another proxy server.
from telegram.ext import Updater
REQUEST_KWARGS = {
'proxy_url': proxy_url,
'urllib3_proxy_kwargs': {
'retries': 0
}
}
updater = Updater(token=TELEGRAM_TOKEN, request_kwargs=REQUEST_KWARGS)
queue = updater.start_polling(bootstrap_retries=0)
.....
raise MaxRetryError(_pool, url, error or ResponseError(cause))
telegram.vendor.ptb_urllib3.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot877422445:AAEGBD0D9stJKMF6PvCClChx8MNMGX-vLEY/deleteWebhook (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x11572df98>: Failed to establish a new connection: [Errno 61] Connection refused')))
......
telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot877422445:AAEGBD0D9stJKMF6PvCClChx8MNMGX-vLEY/deleteWebhook (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x11572df98>: Failed to establish a new connection: [Errno 61] Connection refused')))
2019-07-26 16:07:38,553 - telegram.ext.dispatcher - CRITICAL - stopping due to exception in another thread
This way ?
try:
updater = Updater(token=TELEGRAM_TOKEN, request_kwargs=REQUEST_KWARGS)
queue = updater.start_polling(bootstrap_retries=0)
except MaxRetryError:
#doSomething

Requests library get method error in python3.6

When I try to use the requests lib get method I get an error:
(using tkinter)
The error comes from this line:
var.set(get('https://api.ipify.org').text)
the error message says :
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.ipify.org', port=443): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))

ConnectionError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url:

I am getting the Connection error while trying to scrap data from website.
Below is the code I am using.
import requests
import bs4
res=requests.get('https://www.google.com/')
type(res)
soup=bs4.BeautifulSoup(res.text,'lxml')
type(soup)
print(type(soup))
print(soup.prettify())
soup1=soup.select('title')
Below is the complete error message.
raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

Categories