**这是源码,奇了怪了,最后那个for循环中的函数run()只能运行一次,求大神指点**
刚才有个大神回复了还是有点问题,一不小心把问题删除了,重新发布一下,不好意思
#coding=utf8
import itchat
import time
import re
import xian
def run(url):
xian.parse(url)
itchat.auto_login(hotReload=True)
users = itchat.search_friends(name='risk') #获取对方UserName,返回一个列表
print('========================================================================')
user = users[0]['UserName'] #提取指定UserName
print(user)
f = open('/Users/Air/itchat/data2.txt')
lines = f.readlines() #读取全部内容
print(lines)
for i in range(100):
itchat.send(lines[i], toUserName=user) #UserName需要用上面获取的自己修改
print("Success")
f.close()
itchat.run()
for x in range(1,5):
url1 = 'https://m.taobao.com/list/list.htm?'
run(url1)
time.sleep(10)
習慣沉默2017-06-30 09:57:41
I guess it is the last itchat.run()
in run
that causes the itchat
service to be suspended. Due to the suspended service, the first time run()
is called, it cannot exit, resulting in the subsequent Times for
cannot continue to run.
高洛峰2017-06-30 09:57:41
itchat.run will hang, take itchat.autologin and itchat.run outside, and then start a sub-thread to run your own run function, but itchar.run must be placed after the sub-thread is started