開源的,位址在https://github.com/atupal/webqq
等有時間了寫一個完整的cli qq客戶端。
使用方法:python login_qq.py即可
import urllib2
import httplib2
import re
import random
from encryption import QQmd5
import cookielib
import requests
import getpass
import time
import json
import urllib
class webqq:
def __init__(self, user, pwd):
self.cookies = cookielib.CookieJar()
self.opener = urllib2.build_opener(
urllib2.HTTPHandler(),
urllib2.HTTPSHandler(),
urllib2.HTTPCookieProcessor(self.cookies),
)
urllib2.install_opener(self.opener)
self.user = user
self.pwd = pwd
self.mycookie = ";"
#self.clientid = "21485768"
#self.clientid = "34592990"
self.clientid = str(random.randint(10000000, 99999999))
def getSafeCode(self):
url = 'https://ssl.ptlogin2.qq.com/check?uin=' + str(self.user) + '&appid=1003903&js_ver=10017&js_type=0&login_sig=0ihp3t5ghfoonssle-98x9hy4uaqmpvu*8*odgl5vyerelcb8fk-y3ts6c3*7e8-&u1=http%3A%2F%2Fweb2.qq.com%2Floginproxy.html&r=0.8210972726810724'
req = urllib2.Request(url)
#self.mycookie += "confirmuin=" + self.user + ";"
#req.add_header('Cookie', self.mycookie)
req = urllib2.urlopen(req)
#cs = ['%s=%s' % (c.name, c.value) for c in self.cookies]
#self.mycookie += ";".join(cs)
verifycode = re.search(r"'(\d)','(.+)','(.+)'", req.read())
self.check = verifycode.group(1)
self.verifycode1 = verifycode.group(2)
self.verifycode2 = verifycode.group(3)
if self.check == "1":
url = 'https://ssl.captcha.qq.com/getimage?&uin='+str(self.user)+'&aid=1002101&0.45644426648505' + str(random.randint(10,99))
req = urllib2.Request(url)
req = urllib2.urlopen(req)
self.fi = open("./image.jgp", "wb")
while 1:
c = req.read()
if not c:
break
else :self.fi.write(c)
self.fi.close()
self.verifycode1 = raw_input("verifer:")
print self.check, self.verifycode1, self.verifycode2
def loginGet(self):
#cs = ['%s=%s' % (c.name, c.value) for c in self.cookies]
#self.mycookie += ";" "; ".join(cs)
login_url = 'https://ssl.ptlogin2.qq.com/login?u='+self.user +'&p=' + str(QQmd5().md5_2(self.pwd, self.verifycode1, self.verifycode2)) + '&verifycode=' + self.verifycode1 + '&webqq_type=10&remember_uin=1&login2qq=1&aid=1003903&u1=http%3A%2F%2Fweb.qq.com%2Floginproxy.html%3Flogin2qq%3D1%26webqq_type%3D10&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert&action=2-14-32487&mibao_css=m_webqq&t=1&g=1&js_type=0&js_ver=10015&login_sig=0ihp3t5ghfoonssle-98x9hy4uaqmpvu*8*odgl5vyerelcb8fk-y3ts6c3*7e8-'
req = urllib2.Request(login_url)
req.add_header("Referer", "https://ui.ptlogin2.qq.com/cgi-bin/login?target=self&style=5&mibao_css=m_webqq&appid=1003903&enable_qlogin=0&no_verifyimg=1&s_url=http%3A%2F%2Fweb.qq.com%2Floginproxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20121029001")
#req.add_header("Cookie", self.mycookie)
#self.opener.addheaders.append(("Cookie", self.mycookie))
req = urllib2.urlopen(req)
print req.read()
for cookie in self.cookies:
print cookie.name, ":", cookie.value
if cookie.name == 'ptwebqq':
self.ptwebqq = cookie.value
print urllib2.urlopen('http://web2.qq.com/web2/get_msg_tip?uin=&tp=1&id=0&retype=1&rc=0&lv=3&t=1358252543124').read()
#cs = ['%s=%s' % (c.name, c.value) for c in self.cookies]
#self.mycookie += ";" "; ".join(cs)
def loginPost(self):
url = 'http://d.web2.qq.com/channel/login2'
data = 'r=%7B%22status%22%3A%22online%22%2C%22ptwebqq%22%3A%22' + self.ptwebqq + '%22%2C%22passwd_sig%22%3A%22%22%2C%22clientid%22%3A%22'+self.clientid+'%22%2C%22psessionid%22%3Anull%7D&clientid='+self.clientid+'&psessionid=null'
req = urllib2.Request(url, data)
#req.add_header('Cookie', self.mycookie)
req.add_header('Referer', 'http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=2')
req = urllib2.urlopen(req)
self.result = json.load(req)
print self.result['result']['vfwebqq'], self.result['result']['psessionid']
def getGroupList(self):
url = 'http://s.web2.qq.com/api/get_group_name_list_mask2'
data = 'r=%7B%22vfwebqq%22%3A%22'+self.result['result']['vfwebqq'] +'%22%7D'
req = urllib2.Request(url, data)
req.add_header('Referer', 'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=1')
req = urllib2.urlopen(req)
self.group = json.load(req)
pass
def getFriend(self):
url = 'http://s.web2.qq.com/api/get_user_friends2'
data = 'r=%7B%22vfwebqq%22%3A%22'+self.result['result']['vfwebqq'] +'%22%7D'
req = urllib2.Request(url, data)
req.add_header('Referer', 'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=1')
req = urllib2.urlopen(req)
self.friend = json.load(req)
print self.friend
pass
def getMeg(self):
print urllib2.urlopen('http://web2.qq.com/web2/get_msg_tip?uin=&tp=1&id=0&retype=1&rc=0&lv=3&t=1358252543124').read()
pass
def poll2(self):
url = 'http://d.web2.qq.com/channel/poll2'
data ='r={"clientid":"' self.clientid '","psessionid":"' self.result[ 'result']['psessionid'] '","key":0,"ids":[]}&clientid=' self.clientid '&psessionid=' self.result['result']['psessionid']
req = urllib2.Request(url, data)
#req.add_header('Cookie', self.mycookie)
req.add_header('Referer', 'http://d.web2.qq.com /proxy.html?v=20110331002&callback=1&id=3')
結果= json.load(urllib2.urlopen(req))
列印結果
def sendMsg(self, uin, msg):
url = 'http://d.web2.qq.com/channel/send_buddy_msg2'
data = 'r={"to":'uin',"face":237,"content' urllib.quote( r'":"["'msg r'","\n【提示:此使用者正在使用shift webQq】",["font",{"name":"宋體","size":"10", "樣式":[0,0,0],"顏色":"000000"}]]","') 'msg_id":13190001,"clientid":"'self.clientid '","psessionid":" ' self.result['result']['psessionid'] '"}&clientid=' self.clientid '&psessionid=' self.result['result']['psessionid']
req = urllib2.Request(url , 資料)
#req.add_header('Cookie', self.mycookie)
req.add_header('Referer', 'http://d.web2.qq.com/proxy.html?v=20110331002&callback =1&id=2')
print urllib2.urlopen(req).read()
pass
def sendQunMsg(self, uin, msg):
url = 'http://d.web2 .qq.com/channel/send_qun_msg2'
data = 'r={"group_uin":' uin ',"face":237,"content' urllib.quote(r'":"["' msg r' ","\n【提示:該使用者正在使用shift webQq】",["font",{"name":"宋體","size":"10","style":[0,0,0] ,"color":"000000"}]]","') 'msg_id":13190001,"clientid":"' self.clientid '","psessionid":"' self.result['結果'][' psessionid'] '"}&clientid=' self.clientid '&psessionid=' self.result['result']['psessionid']
req = urllib2.Request(url, data)
req.add_header(' Referer', 'http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=2')
print urllib2.urlopen(req).read()
pass
def main():
user = raw_input('QQ:')
pwd = getpass.getpass('密碼:')
qq = webqq(user, pwd)
qq.getSafeCode()
qq.loginGet()
qq.loginPost()
qq.getGroupList()
qq.getFriend()
while 0:
time.sleep(0.5)
while 0:
time.sleep(0.5)
qq.poll2()
for i in range(100):
print 'to', qq.friend['result']['info'][0]['uin']
print ' to', qq.group['結果']['gnamelist'][10]
#qq.sendMsg(str(qq.friend['結果']['訊息'][0]['uin'] ), 'clientjsfzhiyong')
ms = ''
for _ in xrange(i):
ms = '。 'gnamelist'][10]['gid']), ms)
#qq.sendMsg('2236071402', 'geisf')
if __name__ == "__main__":
main()

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Atom編輯器mac版下載
最受歡迎的的開源編輯器