python:基於itchat實現尋找清理殭屍粉

來源:互聯網
上載者:User


首先 pip3 install itchat

代碼如下


#!/usr/bin/python2.7# -*- coding: utf-8 -*-import itchatimport jsonimport randomimport sysreload(sys)sys.setdefaultencoding('utf8')# 擷取處理分組def create_process_list(process_size):    process_list = []    default_process_size = 35    process_group_size = process_size / default_process_size    if process_size % default_process_size > 0:        process_group_size = process_group_size + 1    for i in range(process_group_size):        start = (i * default_process_size)        end = start + default_process_size        if end > process_size:            end = process_size        process_list.append({'start': start, 'end': end})    return process_listdef get_delete_user_list(start, end, friends):    print 'start run get_delete_user start: ' + str(start) + ', end: ' + str(end)    process_member_list = friends[start:end]    member_dict = {}    for member in process_member_list:        member_dict[member['UserName']] = member        print member['NickName'] + '-----' + str(start)    group_name = 'g1' + str(random.randint(0,1199))    print 'group_name:' + group_name    result = itchat.create_chatroom(process_member_list, group_name)    print 'result: ' + json.dumps(result)    result_member_list = result['MemberList']    delete_list = []    for result_member in result_member_list:        print '---------------member-------------'        print json.dumps(result_member)        if result_member['MemberStatus'] == 4:  # 被對方刪除了            delete_list.append(result_member['UserName'])            print '這個人刪除了我' + result_member['UserName']    return delete_listitchat.auto_login(hotReload=True)friends = itchat.get_friends()friends_len = len(friends)print '列印好友數量:' + str(friends_len)process_list = create_process_list(friends_len)delete_user_list = []for process in process_list:    start = process['start']    end = process['end']    list = get_delete_user_list(start, end, friends)    print '刪除我的人數:' + str(len(list))# list = get_delete_user_list(170, 173, friends)# print '刪除我的人數:' + str(len(list))# print '刪除我的人數:' + str(len(delete_user_list))# foritchat.dump_login_status()




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.