Exemple #1
0
def get_mps(mp_name, update=False):
    """
    根据公众号的名称获取用户数据
    :param mp_name: str 用户名
    :param update: bool 强制更新用户数据
    :return: obj 单个公众号信息
    """
    if update: itchat.get_mps(update=True)
    if not mp_name: return None
    mps = itchat.search_mps(name=mp_name)
    if not mps: return None
    # mpuuid = mps[0]['UserName'] 公众号的uuid
    return mps[0]
Exemple #2
0
def login_callback():
    global CLASS_SIX_ROOM
    target_mp_nickname = ROBBERY_CONFIG["mp"]
    for member in itchat.get_mps():
        if member["NickName"] == target_mp_nickname:
            TARGET_MP = member["UserName"]
            break

    def call():
        print("Sending message:[%s] at: %s" %
              (ROBBERY_CONFIG["message"], datetime.now()))
        itchat.send(msg=ROBBERY_CONFIG["message"], toUserName=TARGET_MP)

    if "clock" in ROBBERY_CONFIG:
        target = datetime.strptime(ROBBERY_CONFIG["clock"],
                                   "%Y-%m-%d %H:%M:%S")
        now = datetime.now()
        delay = (target - now).total_seconds()
        GLOBAL_scheduler.enter(delay, 1, call)
        GLOBAL_scheduler.enter(delay + 1, 1, call)
        print("Will send msg in %s and %s seconds" % (delay, delay + 1))
        GLOBAL_scheduler.run()
    else:
        call()

    itchat.utils.clear_screen()
    if os.path.exists("./QR.png"):
        os.remove("./QR.png")
Exemple #3
0
def login():
    '登录微信网页版'
    uuid = open_QR()
    waitForConfirm = False
    while 1:
        status = itchat.check_login(uuid)
        if status == '200':
            break
        elif status == '201':
            if waitForConfirm:
                output_info('Please press confirm')
                waitForConfirm = True
        elif status == '408':
            output_info('Reloading QR Code')
            uuid = open_QR()
            waitForConfirm = False
    userInfo = itchat.web_init()
    friends = itchat.get_friends(True)
    chatrooms = itchat.get_chatrooms()
    mps = itchat.get_mps()
    # 测试的时候用
    with open('1.pk', 'wb') as f:
        pickle.dump([friends, chatrooms, mps], f)

    return friends, chatrooms, mps
Exemple #4
0
 def getMps():
     mps = itchat.get_mps()
     mps = itchat.search_mps(name='tkBank')
     #print(mps)
     userName = mps[0]['UserName']
     #itchat.send(msg=question,toUserName = userName)
     return userName
Exemple #5
0
def get_mps():
    try:
        data = json.loads(request.data)
        name = data['name']
        return jsonify({'success': 1, 'data': itchat.get_mps()})
    except Exception as e:
        return jsonify({'success': 0, 'msg': "Error {0}".format(str(e))})
Exemple #6
0
    def get_chat_list(self, param=""):
        refresh = False
        if param:
            if param == "-r":
                refresh = True
            else:
                return "Invalid command: %s." % param
        l = []
        for i in itchat.get_friends(refresh)[1:]:
            l.append(i)
            l[-1]['Type'] = "User"

        for i in itchat.get_chatrooms(refresh):
            l.append(i)
            l[-1]['Type'] = "Group"

        for i in itchat.get_mps(refresh):
            l.append(i)
            l[-1]['Type'] = "MPS"

        msg = "List of chats:\n"
        for n, i in enumerate(l):
            alias = i.get('RemarkName', '') or i.get('DisplayName', '')
            name = i.get('NickName', '')
            x = "%s (%s)" % (alias, name) if alias else name
            msg += "\n%s: [%s] %s" % (n, x, i['Type'])

        return msg
Exemple #7
0
 def get_chats(self, group=True, user=True):
     r = []
     if user:
         t = itchat.get_friends(True) + itchat.get_mps(True)
         t[0]['NickName'] = "File Helper"
         t[0]['UserName'] = "******"
         t[0]['RemarkName'] = ""
         for i in t:
             r.append({
                 'channel_name': self.channel_name,
                 'channel_id': self.channel_id,
                 'name': i['NickName'],
                 'alias': i['RemarkName'] or i['NickName'],
                 'uid': self.get_uid(UserName=i['UserName']),
                 'type': MsgSource.User
             })
     if group:
         t = itchat.get_chatrooms(True)
         for i in t:
             r.append({
                 'channel_name': self.channel_name,
                 'channel_id': self.channel_id,
                 'name': i['NickName'],
                 'alias': i['RemarkName'] or i['NickName'] or None,
                 'uid': self.get_uid(NickName=i['NickName']),
                 'type': MsgSource.Group
             })
     return r
Exemple #8
0
    def login_wechat(self):
        try:
            uuid = self.open_qr()
            self.outputWritten("请扫描二维码 ")
            waitForConfirm = False
            while 1:
                status = itchat.check_login(uuid)
                if status == '200': break
                elif status == '201':
                    if waitForConfirm:
                        self.outputWritten('请进行确认 ')
                        waitForConfirm = True
                    elif status == '408':
                        self.outputWritten('重新加载二维码 ')
                        time.sleep(3)
                    uuid = self.open_qr()
                waitForConfirm = False
                userInfo = itchat.web_init()
            itchat.show_mobile_login()
            print('itchat.show_mobile_login() 执行完成!')
            itchat.get_friends()
            print('itchat.get_friends(update=True)[0:] 执行完成!')
            self.outputWritten('登陆成功!账号为:%s ' % userInfo['User']['NickName'])
            itchat.start_receiving()
            print('itchat.start_receiving() 执行完成!')
            self.refresh_button.setText("已登录:{}".format(
                userInfo['User']['NickName']))
            self.exit_button.setEnabled(True)
        except Exception as e:
            print("登录出错:", e)
            self.outputWritten('登陆出错:{} '.format(e))
            try:
                chatrooms = itchat.get_chatrooms()
                print('chatrooms = itchat.get_chatrooms() 执行完成!')
                print(type(chatrooms))
            except Exception as e:
                self.outputWritten("获取群聊列表出错:{} ".format(e))
                try:
                    friends = itchat.get_friends()
                    print('friends = itchat.get_friends() 执行完成!')
                    print(type(friends))
                except Exception as e:
                    self.outputWritten("获取群聊列表出错:{} ".format(e))
                    try:
                        mps = itchat.get_mps()
                        print('mps = itchat.get_mps() 执行完成!')
                        print(type(mps))
                    except Exception as e:
                        self.outputWritten("获取群聊列表出错:{} ".format(e))
                        if chatrooms and friends and mps:
                            return [chatrooms, friends, mps]

                        def run(self):
                            try:
                                self.refresh_button.setEnabled(False)
                                self.exit_button.setEnabled(True)
                                self.finished_signal.emit(self.login_wechat())
                            except Exception as e:
                                self.outputWritten("运行登录线程出错:{} ".format(e))
Exemple #9
0
def get_public_number():
    # 获取公众号信息
    all=itchat.get_mps()
    print(all)
    # 搜索公众号
    some=itchat.search_mps(userName='******')
    print(some)
    other=itchat.search_mps(name='LitterCoder')
Exemple #10
0
def ask_xiaobing():
    global chatReplyList, controller
    if controller is False:
        return
    # chatBotList.append(msg)
    xiaoBing = filter(lambda x: x.NickName == '小冰',
                      itchat.get_mps()).__next__()
    if (len(chatReplyList) > 0):
        xiaoBing.send(chatReplyList[0].Content)
Exemple #11
0
def get_mps():
    itchat.auto_login(True)

    # mps是公众服务号,还包括小程序
    mps = itchat.get_mps(update=True)
    # 搜索某个公众号
    hello = itchat.search_mps(name='有书书院')
    print(['%s : %s' % (it['NickName'], it['Signature']) for it in mps])
    len(mps)
Exemple #12
0
 def get_mps(update=False):
     ''' fetch massive platforms list
         for options
             - update: if not set, local value will be returned
         for results
             - a list of platforms' info dicts will be returned
         it is defined in components/contact.py
     '''
     return itchat.get_mps(update)
Exemple #13
0
def get_userName():
    ''' 获得小冰和自己的username '''
    try:
        return itchat.search_mps(
            name='小冰')[0]['UserName'], itchat.get_friends()[0]['UserName']
    except IndexError as err:
        print('获取userName出错啦', err)  #需要置顶公众号
        print(itchat.get_mps())
        print('请把公众号置顶!!!')
Exemple #14
0
    def get_mp(self):
        lst_mp = []
        mps = itchat.get_mps()
        for mp_ in mps:
            user = {}
            user["NickName"] = mp_["NickName"]
            user["UserName"] = mp_["UserName"]
            # user["HeadImg"] = itchat.get_head_img(chatroomUserName=user["UserName"])
            lst_mp.append(user)

        return lst_mp
Exemple #15
0
 def __init__(self, caname):
     itchat.auto_login(True)
     global CAName
     CAName = caname
     itchat.run(blockThread=False)
     mps = itchat.get_mps()
     mps = itchat.search_mps(name=CAName)
     for i in range(len(mps)):
         print(str(i) + '.', mps[i]['NickName'])
     id = int(input('找到' + str(len(mps)) + '个公钥认证机构,请输入你想要去认证的机构编号:'))
     self.ca = mps[id]
 def get_data(self):
     mps = itchat.get_mps()
     mps = itchat.search_mps(name='公众号名称')
     if len(mps) > 0:
         userName = mps[0]['UserName']
         self.cur_user_name = userName
         max_len = self.db.disease.count_documents({ 'finished': 0 })
         print('There are still ', max_len, ' diseases needing to be scrapied')
         # 周期性爬取疾病
         # self.scheduler.resume_job('main_schedule')
         self.send_disease_name(self)
     else:
         print('Can\'t find MPS 公众号名称')
def get_info(save_file_path):
    '''
    获取公众号信息
    :param save_file_path:
    :return:
    '''
    # 避免频繁扫描二维码登录
    itchat.auto_login(hotReload=True)
    itchat.dump_login_status()
    # 获取好友信息
    we_friend = itchat.get_friends(update=True)[:]
    friends = we_friend[1:]
    total_numbers = len(friends)
    print('你的好友数量为: {}'.format(total_numbers))
    friend_infos_dict = {}
    for fri_info in friends:
        for key in friend_key:
            if friend_infos_dict.get(key, False):
                friend_infos_dict[key].append(fri_info[key])
            else:
                friend_infos_dict[key] = [fri_info[key]]
    # 保存信息
    fri_save_file_name = os.path.join(save_file_path, '好友信息.csv')
    df = pd.DataFrame(friend_infos_dict)
    df.to_csv(fri_save_file_name, sep=',')

    # 获取公众号信息
    mps = itchat.get_mps(update=True)
    mps_num = len(mps)
    print('你关注的公众号数量: {}'.format(mps_num))

    mps_save_file_name = os.path.join(save_file_path, '公众号信息.csv')
    mps_dict = {}
    for mp in mps:
        for key in mps_key:
            if mps_dict.get(key, False):
                mps_dict[key].append(mp[key])
            else:
                mps_dict[key] = [mp[key]]

    df = pd.DataFrame(mps_dict)
    df.to_csv(mps_save_file_name, sep=',', encoding='utf-8')
Exemple #18
0
def get_friends_info():
    try:
        itchat.auto_login(hotReload=True)
    except:
        itchat.auto_login(hotReload=True, enableCmdQR=True)
    friends_info = itchat.get_friends()
    mps_info = itchat.get_mps()  # 公众号信息
    chartrooms_info = itchat.get_chatrooms()  # 群信息
    head_img_info = itchat.get_head_img()  # 头像信息
    msg_info = itchat.get_msg()
    contact_info = itchat.get_contact()
    for info in chartrooms_info:
        print(info)
    with open('test.jpg', 'wb') as img:
        img.write(head_img_info)
        img.flush()
        img.close()
    with open('wechat_info.txt', 'w', encoding='utf-8') as file:
        for friend in friends_info:
            file.write(str(friend))
            file.write('\n\n\n')
Exemple #19
0
def sign():
    today = int(time.strftime('%y%m%d', time.localtime(time.time())))
    while True:
        print today
        mps = itchat.get_mps()
        #print mps
        mps = itchat.search_mps(name='T00ls')
        print mps
        userName = mps[0]['UserName']
        print userName
        itchat.send("3", toUserName=userName)
        time.sleep(40200)

        if today == int(time.strftime('%y%m%d', time.localtime(time.time()))):
            time.sleep(60)
        else:
            try:
                #itchat.send(msg='3',toUserName='******')
                time.sleep(3)
                #itchat.send(msg='4',toUserName='******')
                today = int(
                    time.strftime('%y%m%d', time.localtime(time.time())))
            except Exception, e:
                print('Error : ' + str(e))
Exemple #20
0
# 其它类型参见[文档](http://itchat.readthedocs.io/zh/latest/)
@itchat.msg_register(itchat.content.TEXT)
def print_content(msg):
    print(msg['Text'])
    itchat.send('dkdkdlslkdjkf', 'filehelper')


itchat.auto_login(hotReload=True)
itchat.run()

# 发送消息, toUserName 使用 'filehelper' 即向文件传输助手发消息
itchat.send('message content', 'toUserName')

# 向微软小冰发消息, UserName = '******'
# 获得小冰的UserName,注意小冰属于公众号
mlist = itchat.get_mps()
for i in mlist:
    if i['NickName'] == '小冰':
        username = i['UserName']
        break
# 向小冰发消息
itchat.send('鱼香肉丝怎么做', username)

# 使用图灵机器人http://www.tuling123.com
import requests
api = 'http://www.tuling123.com/openapi/api'
data = {
    'key': '347ab74551a54885ae7d3edf7932b935',
    'info': '是字开头的成语',
    'userid': '123456',
}
Exemple #21
0
    def search_user(self,
                    UserName=None,
                    uid=None,
                    wid=None,
                    name=None,
                    ActualUserName=None,
                    refresh=False):
        """
        Search for a WeChat "User" (a user, a group/chat room or an MPS account,
        by `UserName`, unique ID, WeChat ID, name/alias, and/or group member `UserName`.

        At least one of `UserName`, `uid`, `wid`, or `name` should be provided.

        When matching for a group, all of `UserName`, `uid`, `wid`, and `name` will be used
        to match for group and member.

        Args:
            UserName (str): UserName of a "User"
            uid (str): Unique ID generated by the channel
            wid (str): WeChat ID.
            name (str): Name or Alias
            ActualUserName (str): UserName of a group member, used only when a group is matched.
            refresh (bool): Refresh the user list, False by default.

        Returns:
            list of dict: A list of matching users in ItChat user dict format.
        """
        result = []
        UserName = None if UserName is None else str(UserName)
        uid = None if uid is None else str(uid)
        wid = None if wid is None else str(wid)
        name = None if name is None else str(name)
        ActualUserName = None if ActualUserName is None else str(
            ActualUserName)

        if all(i is None for i in [UserName, uid, wid, name]):
            raise ValueError(
                "At least one of [UserName, uid, wid, name] should be given.")

        for i in itchat.get_friends(refresh) + itchat.get_mps(refresh):

            if str(crc32(i.get('NickName', '').encode("utf-8"))) == uid or \
               str(i.get('UserName', '')) == UserName or \
               str(i.get('Uin', '')) == uid or \
               str(i.get('AttrStatus', '')) == uid or \
               str(i.get('Alias', '')) == wid or \
               str(i.get('NickName', '')) == name or \
               str(i.get('DisplayName', '')) == name:
                result.append(i.copy())
        for i in itchat.get_chatrooms(refresh):
            if not i.get('MemberList', ''):
                i = itchat.update_chatroom(i.get('UserName', ''))
            if str(crc32(i.get('NickName', '').encode("utf-8"))) == uid or \
               str(i.get('Uin', '')) == uid or \
               str(i.get('Alias', '')) == wid or \
               str(i.get('NickName', '')) == name or \
               str(i.get('DisplayName', '')) == name or \
               str(i.get('UserName', '')) == UserName:
                result.append(i.copy())
                result[-1]['MemberList'] = []
                if ActualUserName:
                    for j in itchat.search_chatrooms(
                            userName=i['UserName'])['MemberList']:
                        if str(j['UserName']) == ActualUserName or \
                           str(j['AttrStatus']) == uid or \
                           str(j['NickName']) == name or \
                           str(j['DisplayName']) == name:
                            result[-1]['MemberList'].append(j)
        if not result and not refresh:
            return self.search_user(UserName,
                                    uid,
                                    wid,
                                    name,
                                    ActualUserName,
                                    refresh=True)
        return result
Exemple #22
0
            img = Image.open(files[i] + ".jpg")
        except IOError:
            print(i)
            print("Error")
        else:
            img = img.resize((each_size, each_size), Image.ANTIALIAS)  #缩放图片
            image.paste(img,
                        (x * each_size, y *
                         each_size))  #将缩放的图片黏贴到白色背景上面,x,y为横纵坐标的相对位置,即图片放置的位置
            x += 1
            if x == lines:
                x = 0
                y += 1
    image.save("all.jpg")
    print '图片合并完成!'
    time.sleep(0.1)
    #通过文件传输助手发送到自己微信中
    itchat.send_image("all.jpg", 'filehelper')
    print '发送完成!'
    time.sleep(0.3)
    image.show()

if __name__ == '__main__':
    itchat.login()
    friends = itchat.get_friends(update=True)[0:]  #爬取自己好友相关信息, 返回一个json文件
    mps = itchat.get_mps(update=True)[0:]  #爬取公众号相关信息, 返回一个json文件
    # main(friends,mps)
    friend()
    friend_info()
    mps_info()
    img_friend()
#coding=utf-8
import itchat

from itchat.storage.templates import Chatroom
from itchat.storage.templates import User
from itchat.storage.templates import MassivePlatform

itchat.auto_login()
list_contact = itchat.get_contact()
list_chatrooms = itchat.get_chatrooms()
list_friends = itchat.get_friends()
list_mps = itchat.get_mps()

print(list_contact[0].keys())
print(list_chatrooms[0].keys())
print(list_friends[0].keys())
print(list_mps[0].keys())
Exemple #24
0
#返回完整的好友列表
fs = wx.get_friends()

fs[0]['UserName']

wx.search_friends(
    userName='******'
)

#nickname
wx.search_friends(name='柴小起')

wx.search_friends(wechatAccount='littlecodersh')

wx.get_mps()  #将返回完整的工作号列表(通讯录里的公众号)

get_chatrooms  #返回完整的群聊列表.

search_chatrooms  #群聊搜索.

memberList = itchat.get_frients()[1:]
# 创建群聊, topic 键值为群聊名称.
chatroomUserName = itchat.create_chatroom(memberList, "test chatroom")
# 删除群聊内的用户
itchat.delete_member_from_chatroom(chatroomUserName, memberList[0])
# 增加用户进入群聊.
itchat.add_member_into_chatroom(chatroomUserName,
                                memberList[0],
                                useInvitation=False)
Exemple #25
0
# coding=utf8
import itchat, time

itchat.auto_login(True)

SINCERE_WISH = u'祝%s新年快乐!'
a = itchat.get_friends(update=True)
itchat.get_chatrooms(update=True)
itchat.get_contact(update=True)

itchat.get_mps(update=True)
itchat.get_msg()

friendList = itchat.get_friends(update=True)[1:]
for friend in friendList:
    # 如果是演示目的,把下面的方法改为print即可
    # itchat.send(SINCERE_WISH % (friend['DisplayName']
    #                             or friend['NickName']), friend['UserName'])
    print("%s , %s" %
          (friend['DisplayName'] or friend['NickName'], friend['UserName']))
    # time.sleep(.5)
Exemple #26
0
def maketab(lis):
    labels = '性别不明', '男', '女'
    bili = list(lis.values())
    plt.axes(aspect=1)  #使x y轴比例相同
    explode = [0, 0, 0]  # 突出某一部分区域
    plt.rc('font', size=20)
    plt.pie(x=bili, labels=labels, autopct='%.0f%%', explode=explode)
    f = plt.gcf()
    f.canvas.draw()
    data = np.fromstring(f.canvas.tostring_rgb(), dtype=np.uint8, sep='')
    data = data.reshape(f.canvas.get_width_height()[::-1] + (3, ))
    return Image.fromarray(data)


if __name__ == "__main__":
    starttime = datetime.datetime.now()
    itchat.login()
    print("这个程序可能执行得很慢(在我电脑上有时要等上七八分钟),我暂时也不知道为什么,因为我一开始写的时候忘记加注释了,所以可能看着很臃肿")
    global friends, mpsList
    friends = itchat.get_friends(update=True)[0:]
    mpsList = itchat.get_mps(update=True)[0:]
    getinformation({
        'City': 0,
        'Sex': 1,
        'Signature': 0
    }, {
        'NickName': 0,
        'Signature': 0
    }, r"123.png")
    endtime = datetime.datetime.now()
    print(endtime - starttime)
Exemple #27
0
def run(tl_key,
        p_bans=tuple(),
        g_bans=tuple(),
        p_open=True,
        g_open=True,
        qr=2,
        enable_cfg=False,
        cfg_name="wxReply"):
    """
    启动
    :param tl_key:  图灵key
    :param p_bans:  好友黑名单
    :param g_bans:  群组黑名单
    :param p_open:  开启自动回复
    :param g_open:  开启群艾特回复
    :param qr:      二维码类型
    :param enable_cfg:  是否启用配置文件
    :return: 
    """

    print("""

    ,---------. .-./`)    ____    ,---.   .--.   .-'''-. .---.  .---.   .---.      
    \          \\ .-.') .'  __ `. |    \  |  |  / _     \|   |  |_ _|   | ,_|      
     `--.  ,---'/ `-' \/   '  \  \|  ,  \ |  | (`' )/`--'|   |  ( ' ) ,-./  )      
        |   \    `-'`"`|___|  /  ||  |\_ \|  |(_ o _).   |   '-(_{;}_)\  '_ '`)    
        :_ _:    .---.    _.-`   ||  _( )_\  | (_,_). '. |      (_,_)  > (_)  )    
        (_I_)    |   | .'   _    || (_ o _)  |.---.  \  :| _ _--.   | (  .  .-'    
       (_(=)_)   |   | |  _( )_  ||  (_,_)\  |\    `-'  ||( ' ) |   |  `-'`-'|___  
        (_I_)    |   | \ (_ o _) /|  |    |  | \       / (_{;}_)|   |   |        \ 
        '---'    '---'  '.(_,_).' '--'    '--'  `-...-'  '(_,_) '---'   `--------` 

    """)

    global OPEN_CHAT, OPEN_GROUP, ENABLE_CFG, CFG_NAME

    # 配置文件名称
    CFG_NAME = cfg_name

    # 设置图灵key
    tl_data['key'] = tl_key

    ENABLE_CFG = enable_cfg
    # 配置信息
    if ENABLE_CFG:
        # 读配置
        cfg = get_cfg()
        if cfg:
            p_open = cfg.get('p_open')
            g_open = cfg.get('g_open')
            p_bans = cfg.get('p_bans')
            g_bans = cfg.get('g_bans')

    # 设置回复状态
    OPEN_CHAT = p_open
    OPEN_GROUP = g_open

    # 配置itchat
    itchat.auto_login(hotReload=True,
                      enableCmdQR=qr,
                      statusStorageDir=pkl_path)
    # 默认黑名单
    for ban in p_bans:
        try:
            add_p_ban(ban)
        except Exception as ex:
            print(ex)
            continue

    # 设置群黑名单
    for ban in g_bans:
        try:
            add_g_ban(ban)
        except Exception as ex:
            print(ex)
            continue

    # 获取公众号列表
    for ban in itchat.get_mps(update=True):
        m_ban.add(ban['UserName'])

    # 提示信息
    send_to_file_helper('输入“/菜单”指令,获得帮助。')

    # 写配置
    set_cfg(ENABLE_CFG)

    # 定时清理历史消息
    t = threading.Thread(target=clear, args=(msgs, ))
    t.setDaemon(True)
    t.start()
    # 启动
    itchat.run()
Exemple #28
0
 def initialize(self):
     itchat.auto_login(enableCmdQR=True, hotReload=True)
     self.mps = itchat.get_mps(update=False)
     self.friends = itchat.get_friends(update=False)
Exemple #29
0
def update_mp_map():
    mps = itchat.get_mps()
    for mp in mps:
        mp_mapping[mp["UserName"]] = mp["NickName"]
Exemple #30
0
def get_mps(mp_name, update=False):
    if update: itchat.get_mps(update=True)
    if not mp_name: return None
    mps = itchat.search_mps(name=mp_name)
    if not mps: return None
    return mps[0]
Exemple #31
0
#coding=utf8
import itchat
from pandas import Series, DataFrame

itchat.auto_login(hotReload=True)  #设置为自动 登录

friends = itchat.get_friends(update=True)[0:]
maps = itchat.get_mps(update=True)[0:]
chatroms = itchat.get_chatrooms(update=True)[0:]

#print maps
#print type(friends)

ff = DataFrame(friends)  #好友列表
fmaps = DataFrame(maps)  #公众号列表
fchatroms = DataFrame(chatroms)  #群聊列表

obj1 = ff.reindex([1])
print obj1

#print fchatroms
#print fchatroms.columns

#将数据写入文件保存,编码格式设置为utf-8
fchatroms.to_csv('itchat_chatroms.csv', encoding='utf-8')
fmaps.to_csv('itchat_maps.csv', encoding='utf-8')
ff.to_csv('itchat_data.csv', encoding='utf-8')

#print friends[0:100]
#ac=['sss','sasasas']
#values = ','.join(str(v) for v in value_list)