写了一个小的爬虫,准备用APScheduler间隔调用,在scheduler.add_job方法中报错'func must be a callable or a textual reference to one',看了APScheduler的源代码也找不到解决办法,代码如下
def sprider():
scrapy = WebScrapy()
scrapy.setUp()
scrapy.infoLoad()
scrapy.writeExcel()
print("The End! %s" % time.strftime("%Y%m%d %H:%M:%S", time.localtime()))
if name == "__main__":
scheduler = BackgroundScheduler()
# scheduler.add_job(run ,'cron', hour='3-4', minute='*', second='*/900')
scheduler.add_job(func=sprider(), trigger='interval', id='myrun', minutes=2)
try:
scheduler.start()
print(time.strftime("%Y%m%d %H:%M:%S", time.localtime()))
except (KeyboardInterrupt, SystemExit):
scheduler.shutdown()
print('Errors!')
如果给sprider()随便加一个字符串返回值,则会报错ref-to-obj(func),找不到模块ref这类的错
求大神指教啊