我正在尝试从5个下拉列表中提取所有可能的输出组合(作为树深度),并从中生成一个通用的树数据结构
我在下拉选项中的for选项中有请求,spider只对每个for循环迭代一次
def parse(self, response):
lastPos = response.meta['lastPos']
ending = False
for dropDown in reversed(response.css('select')):
if ending == True:
break
dropId = dropDown.css('::attr(id)').get()
options = dropDown.css('option::text').getall()
for option in options:
if option != self.root:
self.dropDict[dropId] = option
request = scrapy.FormRequest(url=response.url, formdata=self.dropDict, callback=self.parse)
request.meta['lastPos'] = option
return request
蜘蛛需要遍历16个可能的序列,但我只能得到第一个序列,它总是选择第一个下拉选项。我不能寄蜘蛛的回信,它有用吗
使用
yield request
而不是retutn request
相关问题 更多 >
编程相关推荐