Skip to content

Commit f10f209

Browse files
author
vincent
committed
修复由于登录链接变 https 的错误
1 parent fa2f2fa commit f10f209

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

weChat/base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def __init__(self, email=None, password=None):
2323
if not email or not password:
2424
raise ValueError
2525
self.setOpener()
26-
url_login = "http://mp.weixin.qq.com/cgi-bin/login?lang=en_US"
26+
27+
url_login = "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN"
2728
m = hashlib.md5(password[0:16])
2829
m.digest()
2930
password = m.hexdigest()
@@ -33,6 +34,7 @@ def __init__(self, email=None, password=None):
3334
except urllib2.URLError:
3435
raise ClientLoginException
3536
if msg['ErrCode'] not in (0, 65202):
37+
print msg
3638
raise ClientLoginException
3739
self.token = msg['ErrMsg'].split('=')[-1]
3840
time.sleep(1)
@@ -43,16 +45,15 @@ def setOpener(self):
4345
"""
4446
self.opener = poster.streaminghttp.register_openers()
4547
self.opener.add_handler(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
46-
self.opener.addheaders = [('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
47-
('Accept-Charset', 'GBK,utf-8;q=0.7,*;q=0.3'),
48-
('Accept-Encoding', 'gzip,deflate,sdch'),
48+
self.opener.addheaders = [('Accept', 'application/json, text/javascript, */*; q=0.01'),
49+
('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'),
50+
('Referer', 'https://mp.weixin.qq.com/'),
4951
('Cache-Control', 'max-age=0'),
5052
('Connection', 'keep-alive'),
5153
('Host', 'mp.weixin.qq.com'),
5254
('Origin', 'mp.weixin.qq.com'),
5355
('X-Requested-With', 'XMLHttpRequest'),
54-
('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 '
55-
'(KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22')]
56+
('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36')]
5657

5758
def _sendMsg(self, sendTo, data):
5859
"""

0 commit comments

Comments
 (0)