标签:qq技巧大全,qq飞车技巧,qq聊天技巧,
腾讯QQ空间登录的方法实现方式与验证过程分析,http://www.dxs89.com
021
022def Get_qzone2_val(self,username,password):
023 verifyURL = 'http://ptlogin2.qq.com/check?uin=%s&appid=15000101'% username
024 loginURL = 'http://ptlogin2.qq.com/login?'
025 redirectURL = ''
026 cookie = ''
027 qqn = username
028 md5Pass = ''
029 verifyCode = ''
030 result = urlfetch.fetch(url=verifyURL,method=urlfetch.GET,
031 follow_redirects = False,headers={
032 'Content-Type': 'application/x-www-form-urlencoded',
033 'user-agent':'Mozilla/5.0 (Linux; U; Linux i686; en-US) AppleWebKit/525.13 (KHTML, like Gecko)_chrome/0.4.2.80 Safari/525.13',
034 },)
035 logging.info(result.content)
036 cookie1 = Cookie.SimpleCookie(result.headers.get('set-cookie', ''))
037 verifyCode=result.content[18:-3]
038 loginURL += "u=%s&p="% username
039 loginURL+=self.EncodePasswordWithVerifyCode(password,verifyCode)
040 loginURL += "&verifycode="+verifyCode+"&aid=15000101&u1=http%3A%2F%2Fimgcache.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&ptredirect=1&h=1&from_ui=1&fp=loginerroralert"
041 result=urlfetch.fetch(url=loginURL,
042 headers={'Referer':'http://t.qq.com',
043 'Cookie' : self.make_cookie_header(cookie1),
044 'Content-Type': 'application/x-www-form-urlencoded',
045 'user-agent':'Mozilla/5.0 (Linux; U; Linux i686; en-US) AppleWebKit/525.13 (KHTML, like Gecko)_chrome/0.4.2.80 Safari/525.13',
046 },
047 method=urlfetch.GET,
048 follow_redirects = False,
049 )
050
051 setCookies = result.headers.get('set-cookie', '').split(';')
052 cookie2 = ''
053 cookie2+=setCookies[29]
054 cookie2+=setCookies[7]
055 cookie2+=setCookies[4]
056 cookie2+=';'+setCookies[0]
057 cookie2 = cookie2.replace(',', ';')
058 cookie2 = cookie2[1:]
059 callback_url = result.headers.get('location','http://imgcache.qq.com/qzone/v5/loginsucc.html?para=izone')
060 result,cookie = self.do_redirect(callback_url, cookie2)
061
062
063 return result,cookie
064def Tmp_skey_get(self,cookie):
065 tmp=cookie.split(';')
066 for i in tmp:
067 if i[1:5]=='skey':
068 return i[6:]
069 return None
070
071
072def send_qzone2(self,username,password,content,title,html):
073 """
074 send qzone blog. use username, password,content,title,html.
075 the content parameter like html,but no html tag.
076 """
077 memcachekey='send_qzone2'
078 cookie=''
079 if memcache.get(memcachekey):
080 cookie=memcache.get(memcachekey)
081 logging.info('get cookie from memcache')
082 else:
083 result,oldcookie=self.Get_qzone2_val(username,password)
084 cookie='%s;%s'% (result.headers.get('set-cookie', ''),oldcookie)
085 memcache.set(memcachekey,cookie,36000)
086 logging.info('set cookie')
087 tmphash=self.Tmp_skey_get(cookie)
088 tmphash=self.myhash(tmphash)
089 category='个人日记'
090 form_fields = {
091 "uin":'939567050',
092 "category":htmllib.encoding(category,'gb18030'),
093 "title":title,
094 "content":content,
095 "html":html,
096 "cb_autograph":'1',
097 "topflag":'0',
098 "needfeed":'0',
099 "lp_type":'0',
100 "g_tk":tmphash,
101 "scorr_20100723_":'http://qzs.qq.com/qzone/newblog/v5/editor.html|http://qzs.qq.com/qzone/newblog/v5/editor.html<http://user.qzone.qq.com/939567050/main',
102 }
103 form_data = urllib.urlencode(form_fields)
104 try:
105 result = urlfetch.fetch(url="http://b.qzone.qq.com/cgi-bin/blognew/blog_add",
106 payload=form_data,
107 method=urlfetch.POST,
108 headers={'Referer':'http://imgcache.qq.com/qzone/v5/toolpages/fp_gbk.html',
109 'Cookie' : cookie,
,腾讯QQ空间登录的方法实现方式与验证过程分析