首页 > 解决方案 > SSL: WRONG_VERSION_NUMBER] 使用代理时版本号错误

问题描述

我正在使用 instauto 使用代理在 Instagram 上发布图片。此外,当我关闭代理时,一切正常。但是,当我打开代理时,它给了我这个错误

    ERROR:instauto.api.actions.request:Exception while sending request to https://i.instagram.com/api/v1/zr/token/result/?device_id=android-8cbc4322841e6ac5&token_hash=&custom_device_id=f9c6a86b-8cbc-4322-841e-6ac5d09d5ffc&fetch_reason=token_expired with data: 
 {}
Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\urllib3\connection.py", line 359, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\urllib3\connection.py", line 502, in _connect_tls_proxy
    ssl_context=ssl_context,
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\urllib3\util\ssl_.py", line 432, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\urllib3\util\ssl_.py", line 474, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "C:\Program Files\Python37\lib\ssl.py", line 412, in wrap_socket
    session=session
  File "C:\Program Files\Python37\lib\ssl.py", line 850, in _create
    self.do_handshake()
  File "C:\Program Files\Python37\lib\ssl.py", line 1108, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1045)

整个代码是:


from instauto.api.client import ApiClient
from instauto.api import structs as st
from instauto.api.actions import post as ps

if __name__ == '__main__':
  if os.path.isfile('./.instauto.save'):
      client = ApiClient.initiate_from_file('./.instauto.save')
  else:
      client = ApiClient(user_name=os.environ.get("INSTAUTO_USER") or "my_username", password=os.environ.get("INSTAUTO_PASS") or "my_password")
      client.login()
      client.save_to_disk('./.instauto.save')

  post = ps.PostFeed(
      path='./test_feed.jpg',
      caption='This is an example. Follow me!'
  )
  resp = client.post_post(post, 80)
  print("Success: ", resp.ok)

我已经寻找解决这个问题但我失败了:(。此外,我不确定这个问题是来自代理(似乎工作正常)还是 Instagram。

标签: pythonssl

解决方案


推荐阅读