Edison-

MY CODE AND ERROR!!

Mar 7th, 2021
1,147
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. my code
  2.  
  3. from telegram import *
  4. import requests
  5. from telegram.ext import *
  6.  
  7.  
  8. def set_proxy():
  9.     proxy = '127.0.0.1:1089'  # 本地代理
  10.  
  11.     proxies = {
  12.         'http': 'http://' + proxy,
  13.         'https': 'https://' + proxy
  14.     }
  15.  
  16.     try:
  17.         response = requests.get('http://httpbin.org/get', proxies=proxies)
  18.         print(response.text)
  19.     except requests.exceptions.ConnectionError as e:
  20.         print('错误:', e.args)
  21.  
  22.  
  23. def bot_init():
  24.     bot = Bot("KEY")
  25.     print(bot.get_me())
  26.  
  27.  
  28. set_proxy()
  29. bot_init()
  30.  
  31.  
  32.  
  33. -------my error
  34.  
  35. Traceback (most recent call last):
  36.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
  37.     conn = connection.create_connection(
  38.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection
  39.     raise err
  40.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection
  41.     sock.connect(sa)
  42. socket.timeout: timed out
  43.  
  44. During handling of the above exception, another exception occurred:
  45.  
  46. Traceback (most recent call last):
  47.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
  48.     httplib_response = self._make_request(
  49.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
  50.     self._validate_conn(conn)
  51.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
  52.     conn.connect()
  53.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 353, in connect
  54.     conn = self._new_conn()
  55.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
  56.     raise ConnectTimeoutError(
  57. urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x0000029507EF2A00>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')
  58.  
  59. During handling of the above exception, another exception occurred:
  60.  
  61. Traceback (most recent call last):
  62.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\python_telegram_bot-13.3-py3.9.egg\telegram\utils\request.py", line 252, in _request_wrapper
  63.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\request.py", line 78, in request
  64.     return self.request_encode_body(
  65.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\request.py", line 170, in request_encode_body
  66.     return self.urlopen(method, url, **extra_kw)
  67.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\poolmanager.py", line 375, in urlopen
  68.     response = conn.urlopen(method, u.request_uri, **kw)
  69.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
  70.     return self.urlopen(
  71.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
  72.     return self.urlopen(
  73.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
  74.     return self.urlopen(
  75.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
  76.     retries = retries.increment(
  77.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 573, in increment
  78.     raise MaxRetryError(_pool, url, error or ResponseError(cause))
  79. urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botKEY/getMe (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000029507EF2A00>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)'))
  80.  
  81. The above exception was the direct cause of the following exception:
  82.  
  83. Traceback (most recent call last):
  84.   File "F:\Python\TeleBot\Main.py", line 27, in <module>
  85.     bot_init()
  86.   File "F:\Python\TeleBot\Main.py", line 23, in bot_init
  87.     print(bot.get_me())
  88.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\python_telegram_bot-13.3-py3.9.egg\telegram\bot.py", line 126, in decorator
  89.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\python_telegram_bot-13.3-py3.9.egg\telegram\bot.py", line 407, in get_me
  90.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\python_telegram_bot-13.3-py3.9.egg\telegram\bot.py", line 258, in _post
  91.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\python_telegram_bot-13.3-py3.9.egg\telegram\utils\request.py", line 349, in post
  92.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\python_telegram_bot-13.3-py3.9.egg\telegram\utils\request.py", line 258, in _request_wrapper
  93. telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botKEY/getMe (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000029507EF2A00>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)'))
  94.  
  95. 进程已结束,退出代码为 1
  96.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×