I'm trying to use Pyspider crawler to scan my site, I would like one request to be made every 2 seconds, but currently I know that 3 requests are made at the same time, I could not find the setting to change this parameter.
I found in /usr/lib/python2.7/site-packages/pyspider/scheduler/scheduler.py
file the setting LOOP_INTERVAL
which I set to 2 (seconds) but now every 2 seconds 3 requests are made instead I would only like 1 request every 2 seconds.
Thi is my setting:
from pyspider.libs.base_handler import *
class Handler(BaseHandler):
crawl_config = {
}
@every(minutes=24 * 60)
def on_start(self):
self.crawl('https://example.com/', callback=self.index_page)
@config(age=10 * 24 * 60 * 60)
def index_page(self, response):
for each in response.doc('a[href^="http"]').items():
self.crawl(each.attr.href, callback=self.detail_page)
@config(priority=2)
def detail_page(self, response):
return {
"url": response.url,
"title": response.doc('title').text(),
}
then I would also like the crawler to go only 1 page deep, from where can I change this parameter?
Look here https://docs.pyspider.org/en/latest/About-Projects/#about-projects find rate/burst . I think it will solve your problem . Change to rate/burst = 0.02/1