import json
import time
import datetime
import re
import random
from PIL import Image
import os
class QqQun(object):
headers = {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/73.0.3683.75 Safari/537.36',
'referer': 'https://qun.qq.com/member.html',
'origin': 'https://qun.qq.com'
}
def __init__(self):
self.bkn = None
self.qun = None
self.token = None
self.qrsig = None
self.cookies = None
self.skey = None
def login(self):
if os.path.exists('cookie.txt'):
with open('cookie.txt', 'r') as f:
cookies = f.read().replace("'", '"')
d = json.loads(cookies)
self.cookies = d
self.skey = d.get('skey')
self.get_bkn()
url = 'https://qun.qq.com/cgi-bin/qun_mgr/get_group_list'
data = {'bkn': self.bkn}
r = requests.post(url, headers=self.headers, data=data, cookies=self.cookies)
js_data = json.loads(r.content.decode())
if js_data.get('ec') == 4:
print('cookie已过期,需要重新扫码')
self.img_get()
elif js_data.get('ec') == 0:
print('登入成功')
self.find_qun()
else:
print('出现了一点小状况....')
else:
print('第一次用吧?来来来,扫个码')
self.img_get()
def get_bkn(self):
e = str(self.skey)
t = 5381
n = 0
o = len(e)
while n i:
e += (e