QQ群验证目前被和谐了一堆,就剩下一些内存获取qq群号的方式了,前几天肝了一晚上干出来了个Python版本
有个界面pyqt5弄的能用啥问题联系我qq
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton
global Text
Text = ""
# 先来个窗口
class window(QWidget):
def __init__(self):
super().__init__()
self.setup()
def setup(self):
self.box = QVBoxLayout(self) # 创建一个垂直布局来放控件
self.btn_get = QPushButton('验证') # 创建一个按钮涌来了点击获取cookie
self.btn_get.clicked.connect(self.get_cookie) # 绑定按钮点击事件
self.web = MyWebEngineView() # 创建浏览器组件对象
self.web.resize(450, 330) # 设置大小
self.web.load(QUrl("https://qun.qq.com/member.html#gid=827941147")) # 打开百度页面来测试
self.box.addWidget(self.btn_get) # 将组件放到布局内,先在顶部放一个按钮
self.box.addWidget(self.web) # 再放浏览器
self.web.show() # 最后让页面显示出来
def get_cookie(self):
cookie = self.web.get_cookie()
target = ";skey="
location = cookie.index(target)
target2 = ";"
location2 = cookie[location + 6:].index(target2)
skey = cookie[location + 6:][:location2]
print("skey: " + skey)
def bkn(skey):
e = skey
t = 5381
n = 0
o = len(e)
while n < o:
t += (t << 5) + ord(e[n])
n += 1
return t & 2147483647
print("BKN: " + str(bkn(skey)))
import time
import requests
import json
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36",
"Cookie": cookie
}
end = 40
start = end
for i in range(1, int(1000 / 40) + 1):
st = start * i - 40
en = start * i
data = {'gc': 群号, 'st': st, 'end': en, 'sort': 0, 'bkn': bkn(skey)}
response = requests.post("https://qun.qq.com/cgi-bin/qun_mgr/search_group_members", data=data, headers=headers,verify=False)
qqJson = json.loads(response.text)
global Text
Text = Text + str(qqJson)
print(Text)
res = "群主qq号" in Text
if res == True:
print("验证成功.")
self.gui = BreathToolBox()
self.gui.show()
self.hide()
else:
print("验证失败.")
# 创建自己的浏览器控件,继承自QWebEngineView
class MyWebEngineView(QWebEngineView):
def __init__(self, *args, **kwargs):
super(MyWebEngineView, self).__init__(*args, **kwargs)
# 绑定cookie被添加的信号槽
QWebEngineProfile.defaultProfile().cookieStore().cookieAdded.connect(self.onCookieAdd)
self.cookies = {} # 存放cookie字典
def onCookieAdd(self, cookie): # 处理cookie添加的事件
name = cookie.name().data().decode('utf-8') # 先获取cookie的名字,再把编码处理一下
value = cookie.value().data().decode('utf-8') # 先获取cookie值,再把编码处理一下
self.cookies[name] = value # 将cookie保存到字典里
# 获取cookie
def get_cookie(self):
cookie_str = ''
for key, value in self.cookies.items(): # 遍历字典
cookie_str += (key + '=' + value + ';') # 将键值对拿出来拼接一下
return cookie_str # 返回拼接好的字符串
if __name__ == "__main__":
app = QApplication(sys.argv)
w = window()
w.show()
sys.exit(app.exec_())