谢谢,已经解决了,有个新问题
# -*- coding: utf-8 -*-
import itchat
from itchat.content import TEXT
from itchat.content import *
import requests
from bs4 import BeautifulSoup
r=requests.get('https://s.weibo.com/top/summary?cate=realtimehot')
str1='今日微博热搜消息\n'
if(r.status_code==200):
r.encoding='utf-8'
bs=BeautifulSoup(r.text,features="lxml")
rank=bs.select('.td-02 a')
for index in range(10):
str1+=str(index+1)+'.'+rank[index].text.strip()+'https://s.weibo.com'+rank[index]['href']+'\n'
itchat.auto_login(hotReload=True)
itchat.send(u'Hello,world','filehelper')
groupName=u"测试群" # 你真实微信中的群备注名称.
@itchat.msg_register(TEXT, isGroupChat=True)
def SentChatRoomsMsg(name, context):
itchat.get_chatrooms(update=True)
iRoom = itchat.search_chatrooms(name)
for room in iRoom:
if room['NickName'] == name:
userName = room['UserName']
break
itchat.send_msg(context, userName)
SentChatRoomsMsg(groupName,str1)
print('发送完毕!')
Traceback (most recent call last):
File "D:\Python27\wxpy.py", line 29, in <module>
SentChatRoomsMsg(groupName,str1)
TypeError: 'NoneType' object is not callable
能指导下吗
time.sleep(2)
send_qq(to_who, msg)
i=3
while 1: #a="+"+str(i)
#i=i-1
send_qq(to_who, msg)
time.sleep(600)
f.close
你好,帮忙看看这段代码,总报错NameError: name 'abc' is not defined