我正在写一个蜘蛛到废品的网站:
第一个urlwww.parenturl.com调用解析函数,从那里我提取了urlwww.childurl.com我有一个parse2函数的回调函数,它返回dict
问题1)我需要将dict值与从parse函数中的父url中提取的其他7个值一起存储在mysql数据库中?(响应url打印无)
def parse(self, response):
for i in range(0,2):
url = response.xpath('//*[@id="response"]').extract()
response_url=yield SplashFormRequest(url,method='GET',callback=self.parse2)
print response_url # prints None
def parse2(self, response):
dict = {'url': response.url}
return dict
不能将yield调用等同于变量,因为它的作用类似于返回调用。在
试着把它取下来
因为scrapy的asynchronous nature,所以在spider对象上存储第二次回调的结果并打印它不能保证正常工作。相反,您可以尝试passing additional data to callback functions,类似于:
相关问题 更多 >
编程相关推荐