У меня есть класс, чтобы отбросить некоторые данные:
class SiteSpider(scrapy.Spider):
name = "somesite"
start_urls = ['https://www.somesite.com']
def start_requests(self):
parser = CommentParser()
urls = ['https://www.somesite.com']
for url in urls:
yield scrapy.Request(url=url, callback=parser.scrap)
, который в классе CommentParser у меня есть:
class CommentParser():
def scrap(self, response):
print("from CommentParser.scrap =>", response.url)
for i in range(5):
yield scrapy.Request(url="https://www.somesite.com/comments/?page=%d" % i, callback=self.parse)
def parse(self,response):
print("from CommentParser.parse => ", response.url)
yield dict(response_url = response.url)
, но скрап-доза не отправляет запрос в классе CommentParser, и поэтому я могуне получить ответ в CommentParser.parse