恩, 很久没发python小工具了, 现在来发点=.=
串群检查 – 检查两个或多个QQ群里相同的QQ号, 输出每个QQ号在哪些群及在各群的马甲.
输入格式:
1群: 1.txt
2群: 2.txt
…
把1.txt, 2.txt, 3.txt等文件和下面的py脚本放一个目录里, 然后运行py脚本即可~
下面就是代码啦~
v0.2 – 2011/01/18
重写了算法, 速度更快
增加了全部群友信息输出, 方便管理员查找
感谢牛B轰轰的吉米大大贡献代码!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#coding:utf-8 #!/usr/bin/env python # QQ 串群检查 - By Felix Yan GPL v3 # felixonmars@gmail.com # http://blog.felixc.at import sys chuanqun = [] ren = [] for i in range(1,100): try: f = open("%d.txt" % (i), "r") for line in f: try: tmp = line.decode(sys.getfilesystemencoding()).strip().split() qq = tmp[-1] nick = tmp[0] ren.append([qq, [str(i), nick]]) except: pass except IOError: pass #下面这段精妙的代码是吉米大大的!!!!!!!!! d = {} l = [] for i, j in ren: try: d[i] += [j] except KeyError: d[i] = [j] for i in d.keys(): l += [[i] + d[i]] l.sort(key=lambda x:int(x[0])) ren = l for i in ren: if len(i[1:]) > 1: chuanqun.append(i) chuanqun.sort(key=lambda x:len(x[1:]), reverse=True) resultchuan = [] for i in chuanqun: resultchuan.append(u"%s 串群 %s" % (i[0], ", ".join([u"%s群(%s)" % (x[0], x[1]) for x in i[1:]]))) f = open(u"串群检查结果.txt".encode(sys.getfilesystemencoding()), "w") f.write("\n".join(resultchuan).encode(sys.getfilesystemencoding())) f.close() resultall = [] for i in ren: resultall.append(u"%s 在 %s" % (i[0], ", ".join([u"%s群(%s)" % (x[0], x[1]) for x in i[1:]]))) f = open(u"全部群员信息.txt".encode(sys.getfilesystemencoding()), "w") f.write("\n".join(resultall).encode(sys.getfilesystemencoding())) f.close() |
v0.1 – 2011/01/17
第一个版本=.=
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#coding:utf-8 #!/usr/bin/env python # QQ 串群检查 - By Felix Yan GPL v3 # felixonmars@gmail.com # http://blog.felixc.at import sys chuanqun = [] ren = [[] for i in range(100)] for i in range(1,100): try: f = open("%d.txt" % (i), "r") for line in f: try: tmp = line.decode(sys.getfilesystemencoding()).strip().split() qq = tmp[-1] nick = tmp[0] ren[i].append([qq, nick]) except: pass except IOError: pass for qun in enumerate(ren): for qq in qun[1]: newset = False for qun2 in enumerate(ren[qun[0] + 1:]): if qun2[0] != qun[0]: for qq2 in qun2[1]: if qq[0] == qq2[0]: flag = False for item in chuanqun: if item[0] == qq[0]: flag = True if newset: item.append(u"%d群(%s)" % (qun[0] + qun2[0] + 1, qq2[1])) if not flag: newset = True chuanqun.append([qq[0], u"%d群(%s)" % (qun[0], qq[1]), u"%d群(%s)" % (qun[0] + qun2[0] + 1, qq2[1])]) chuanqun.sort(key=lambda x:len(x[1:]),reverse=True) result = [] for i in chuanqun: result.append(u"%s 串群 %s" % (i[0], ", ".join(i[1:]))) f = open(u"串群检查结果.txt".encode(sys.getfilesystemencoding()), "w") f.write("\n".join(result).encode(sys.getfilesystemencoding())) f.close() |
看上去会有些用处~~
1群: 1.txt
2群: 2.txt
这些群友资料是怎么导出的?
从QQ群空间点管理员功能里, 可以看到一个所有群友的表格, 复制下来不加处理的贴到txt里, 就是这些群友资料了:)
我只看到通讯录,好多页啊。。
管理员可以直接看全部的…
orz只有管理员能用么
普通成员用一些助手类的软件提取出来的列表也可以用.
这个。。。QQ就挂着,偶尔去麦田圈唠叨一下。。。被逼的,你懂得。
这个有点意思,回头我扫扫群里看看你有马甲没。
好注目的楼梯