1

我想设置随机时间间隔和蟒蛇叫迭代之间的函数/ scrapy如何在scrapy/python中设置随机时间间隔?

注意:如何设置迭代和功能之间的随机时间间隔在Python scrapy

import random 
 

 

 
class MySpider(CrawlSpider): 
 

 
\t def xxxxxx(self): 
 
     xxxxxx 
 

 
\t def xxxx(self,response): 
 
\t \t for list in lists: 
 
         
 
\t \t for xxxxxxx: 
 
          item = example() 
 
          yield request 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t \t 
 
\t def xxxxxx(self, response): 
 
\t \t item=response.meta['item'] 
 
\t 
 
\t \t return item

回答

0

也许这可以工作,因为scrapy是基于扭曲的框架

import random 
from twisted.internet import reactor 

INTERVAL = xxxx 
def callRandomTime(): 
    youFunc() 
    reactor.callLater(INTERVAL * random.random(), callRandomTime) 
相关问题