我正在尝试设置随机时间间隔,并在python / scrapy
中的迭代之间调用该函数注意:如何在python scrapy中设置迭代和函数之间的随机时间间隔
import random
class MySpider(CrawlSpider):
def xxxxxx(self):
xxxxxx
def xxxx(self,response):
for list in lists:
for xxxxxxx:
item = example()
yield request
def xxxxxx(self, response):
item=response.meta['item']
return item

答案 0 :(得分:0)
也许这可以起作用,因为scrapy是一个基于扭曲的框架
import random
from twisted.internet import reactor
INTERVAL = xxxx
def callRandomTime():
youFunc()
reactor.callLater(INTERVAL * random.random(), callRandomTime)