@@ -23,7 +23,8 @@ def __init__(self, email=None, password=None):
23
23
if not email or not password :
24
24
raise ValueError
25
25
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"
27
28
m = hashlib .md5 (password [0 :16 ])
28
29
m .digest ()
29
30
password = m .hexdigest ()
@@ -33,6 +34,7 @@ def __init__(self, email=None, password=None):
33
34
except urllib2 .URLError :
34
35
raise ClientLoginException
35
36
if msg ['ErrCode' ] not in (0 , 65202 ):
37
+ print msg
36
38
raise ClientLoginException
37
39
self .token = msg ['ErrMsg' ].split ('=' )[- 1 ]
38
40
time .sleep (1 )
@@ -43,16 +45,15 @@ def setOpener(self):
43
45
"""
44
46
self .opener = poster .streaminghttp .register_openers ()
45
47
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/ ' ),
49
51
('Cache-Control' , 'max-age=0' ),
50
52
('Connection' , 'keep-alive' ),
51
53
('Host' , 'mp.weixin.qq.com' ),
52
54
('Origin' , 'mp.weixin.qq.com' ),
53
55
('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' )]
56
57
57
58
def _sendMsg (self , sendTo , data ):
58
59
"""
0 commit comments