qq空间怎么删除全部留言,qq空间留言如何全部删除

首页 > 实用技巧 > 作者:YD1662023-05-16 22:34:10

qq空间怎么删除全部留言,qq空间留言如何全部删除(9)

三、源码

import time import requests import json with open('conf.json', 'r', encoding='utf-8') as f: content = f.read() msg = json.loads(content) print(msg) # 你的QQ号 QQ = msg['QQ'] # 浏览器打开QQ空间,按F12,找到g_tk g_tk = msg['g_tk'] # 要删除的对方的备注或昵称(ta在你空间所显示的名称) targetname = msg['name'].split(',') # 浏览器打开QQ空间,按F12,找到cookie cookie = msg['cookie'] print('@'*60) print('>> 你的QQ:', QQ) print('>> 对方名称:', targetname) print('@'*60) print('>> 开始运行') print() headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36', 'cookie': cookie } def getcomment(): delcnt = 0 delmsg = [] totalcomment = 20 pos = 0 while pos < totalcomment: print('#' * 60) print(">> 当前位置:", pos) url = 'https://user.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6?uin={0}&inCharset=utf-8&outCharset=utf-8&hostUin={0}¬ice=0&sort=0&pos={1}&num=20&cgi_host=https://user.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6&code_version=1&format=json&need_private_comment=1&g_tk={2}'.format(QQ, pos, g_tk) pos = 20 html = requests.get(url, headers=headers).json() totalcomment = int(html['total']) print('>> 总共条数:', totalcomment) msglist = html['msglist'] for item in msglist: try: commentlist = item['commentlist'] conlist = item['conlist'] if conlist: conlist = conlist[0]['con'] print(">> 发布的说说:", conlist) else: print(">> 发布仅为图片") topicId = QQ '_' item['tid'] print(">> topicId:", topicId) for i in commentlist: content = i['content'] name = i['name'] createTime = i['createTime'] commentId = commentlist.index(i) 1 print(">> 评论{}: ({}){}\t{}".format(commentId, createTime, name, content)) if name in targetname: print(">> 删除本条留言") delcomment(topicId, commentId) delcnt = 1 delmsg.append(content) print() except: pass time.sleep(1) print('*' * 60) print('共删除条数:', delcnt) print('共删除内容:', delmsg) print('*' * 60) def delcomment(topicId, commentId): url = 'https://user.qzone.qq.com/proxy/domain/taotao.qzone.qq.com/cgi-bin/emotion_cgi_delcomment_ugc?g_tk={0}'.format(g_tk) data={ 'uin': QQ, 'hostUin': QQ, 'topicId': topicId, 'commentId': commentId, 'inCharset':'', 'outCharset':'', 'ref':'', 'hostuin': QQ, 'code_version': '1', 'format': 'fs', 'qzreferrer': 'https://user.qzone.qq.com/proxy/domain/qzs.qq.com/qzone/app/mood_v6/html/index.html#mood&g_iframeUser=1&g_iframedescend=1&uin={0}&pfid=2&qz_ver=8&appcanvas=0&qz_style=31¶ms=&entertime=1588985689146&canvastype=&cdn_use_https=1'.format(QQ) } html = requests.post(url, headers=headers, data=data) time.sleep(1) html = requests.post(url, headers=headers, data=data) if '对不起,原文已经被删除,无法查看' in html.text: print('原文已经被删除') try: getcomment() except Exception as e: print(e) input(">> 任意键退出...")

上一页123末页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.