ly0 / baidupcsapi

百度网盘api
MIT License
1.21k stars 234 forks source link

登录失败, requests.exceptions.SSLError? #38

Closed MMmaomao closed 8 years ago

MMmaomao commented 8 years ago

求指教, 登录遇到错误

from baidupcsapi import PCS
pcs = PCS("mmmaomao", "***********")
C:\Users\admin\Envs\baidu\lib\site-packages\requests\packages\urllib3\util\ssl_.
py:100: InsecurePlatformWarning: A true SSLContext object is not available. This
 prevents urllib3 from configuring SSL appropriately and may cause certain SSL c
onnections to fail. For more information, see https://urllib3.readthedocs.org/en
/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
C:\Users\admin\Envs\baidu\lib\site-packages\requests\packages\urllib3\connection
.py:264: SubjectAltNameWarning: Certificate for passport.baidu.com has no `subje
ctAltName`, falling back to check for a `commonName` for now. This feature is be
ing removed by major browsers and deprecated by RFC 2818. (See https://github.co
m/shazow/urllib3/issues/497 for details.)
  SubjectAltNameWarning
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\admin\Envs\baidu\lib\site-packages\baidupcsapi\api.py", line 40
0, in __init__
    super(PCS, self).__init__(username, password, api_template, captcha_func=cap
tcha_callback)
  File "C:\Users\admin\Envs\baidu\lib\site-packages\baidupcsapi\api.py", line 13
5, in __init__
    self._initiate()
  File "C:\Users\admin\Envs\baidu\lib\site-packages\baidupcsapi\api.py", line 18
3, in _initiate
    self.user['token'] = self._get_token()
  File "C:\Users\admin\Envs\baidu\lib\site-packages\baidupcsapi\api.py", line 21
0, in _get_token
    'https://passport.baidu.com/v2/api/?getapi&tpl=mn&apiver=v3&class=login&tt=%
s&logintype=dialogLogin&callback=0' % int(time.time())).text.replace('\'', '\"')

  File "C:\Users\admin\Envs\baidu\lib\site-packages\requests\sessions.py", line
480, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\admin\Envs\baidu\lib\site-packages\requests\sessions.py", line
468, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\admin\Envs\baidu\lib\site-packages\requests\sessions.py", line
576, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\admin\Envs\baidu\lib\site-packages\requests\adapters.py", line
433, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: hostname 'passport.baidu.com' doesn't match u'baid
u.com'
ly0 commented 8 years ago

python的版本是?

MMmaomao commented 8 years ago

win7 64 image image

MMmaomao commented 8 years ago

用python2.7.10 试了下, 也有同样的报错. 求指教.

ly0 commented 8 years ago

尝试一下 https://github.com/ly0/baidupcsapi/blob/master/baidupcsapi/api.py#L218

改成

        ret = self.session.get(
            'https://passport.baidu.com/v2/api/?getapi&tpl=mn&apiver=v3&class=login&tt=%s&logintype=dialogLogin&callback=0' % int(time.time()), verify=false).text.replace('\'', '\"')
MMmaomao commented 8 years ago

谢谢, 我试一下

MMmaomao commented 8 years ago

可以登录了, 不过false 要改成 False.

MMmaomao commented 8 years ago

非常感谢