upbit / pixivpy

Pixiv API for Python
https://pypi.org/project/PixivPy3/#files
The Unlicense
1.79k stars 149 forks source link

demo ByPassSniApi 错误 #148

Closed qihua closed 3 years ago

qihua commented 3 years ago

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 444, in wrap_socket cnx.do_handshake() File "/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1915, in do_handshake self._raise_ssl_error(self._ssl, result) File "/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1647, in _raise_ssl_error _raise_current_error() File "/usr/local/lib/python3.7/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue raise exception_type(errors) OpenSSL.SSL.Error: [('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 594, in urlopen self._prepare_proxy(conn) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 815, in _prepare_proxy conn.connect() File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 356, in connect sslcontext=context) File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl.py", line 359, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 450, in wrap_socket raise ssl.SSLError('bad handshake: %r' % e) ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='app-api.pixiv.net.cdn.cloudflare.net.', port=443): Max retries exceeded with url: /auth/token (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/jerry/PycharmProjects/pixivpy/pixivpy3/api.py", line 59, in requests_call self.requests_kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 581, in post return self.request('POST', url, data=data, json=json, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python3.7/site-packages/requests_toolbelt/adapters/host_header_ssl.py", line 43, in send return super(HostHeaderSSLAdapter, self).send(request, **kwargs) File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='app-api.pixiv.net.cdn.cloudflare.net.', port=443): Max retries exceeded with url: /auth/token (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/jerry/PycharmProjects/pixivpy/example_bypass_sni.py", line 37, in main() File "/Users/jerry/PycharmProjects/pixivpy/example_bypass_sni.py", line 27, in main api.login(_USERNAME, _PASSWORD) File "/Users/jerry/PycharmProjects/pixivpy/pixivpy3/api.py", line 73, in login return self.auth(username=username, password=password) File "/Users/jerry/PycharmProjects/pixivpy/pixivpy3/api.py", line 109, in auth r = self.requests_call('POST', url, headers=headers, data=data) File "/Users/jerry/PycharmProjects/pixivpy/pixivpy3/api.py", line 64, in requests_call raise PixivError('requests %s %s error: %s' % (method, url, e)) pixivpy3.utils.PixivError: requests POST https://app-api.pixiv.net.cdn.cloudflare.net./auth/token error: HTTPSConnectionPool(host='app-api.pixiv.net.cdn.cloudflare.net.', port=443): Max retries exceeded with url: /auth/token (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])")))

upbit commented 3 years ago

bad handshake意味着SSL的握手失败,不过看解析到的,还是cloudflare的域名: requests POST https://app-api.pixiv.net.cdn.cloudflare.net./auth/token error

感觉是 #138 的那个问题。可以先排除下OpenSSL的版本问题,如果不是可以按 https://github.com/upbit/pixivpy/issues/138#issuecomment-706645066 的方法试试更换Host

qihua commented 3 years ago

@upbit 谢谢,,ip 换成210.140.131.219就Ok 了