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) 
相關問題