[英]How do I use scrapy.Request right way
Im trying to make my crawler crawl the next page so I wrote this function: 我试图让我的搜寻器抓取下一页,所以我写了这个函数:
def requestURL(self, hrefPath):
print(hrefPath)
url = "http://www.presseportal.de/" + hrefPath
yield scrapy.Request(url, callback=self.parse)
Its not even printing the variable hrefPath
so I suspect the function isnt called, although im pretty sure I called it right like this: self.requestURL(hrefPath)
它甚至没有打印变量hrefPath
所以我怀疑函数没有被调用,尽管我很确定我这样调用它: self.requestURL(hrefPath)
Im very new to scrapy so Im very sorry if this question seems stupid 我是新手,所以我很抱歉,如果这个问题看起来很愚蠢
I figured it out: Instead of writing 我弄清楚了:不用写
yield scrapy.Request(url, callback=self.parse)
write return 写回报
yield scrapy.Request(url, callback=self.parse)
in the function and when you call the function in the parse function write: yield requestURL(hrefPath)
在函数中以及在解析函数中调用该函数时,请写: yield requestURL(hrefPath)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.