如何在scrapy/python中设置随机时间间隔?

How to set random time interval in scrapy/python?

我正在尝试设置随机时间间隔并在 python/scrapy

中的迭代之间调用该函数

注意:如何在pythonscrapy

中设置迭代和函数之间的随机时间间隔

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

也许这可行,因为 scrapy 是一个基于 twisted

的框架
import random
from twisted.internet import reactor

INTERVAL = xxxx
def callRandomTime():
    youFunc()
    reactor.callLater(INTERVAL * random.random(), callRandomTime)