我想要使用篩選選項來取消包含comobobox的網頁。 基地址相同,但請求負載取決於選定的組合框值。我有一個可用的選項列表,我創建了一個遍歷組合框值並執行請求的循環。代碼如下:循環中的Scrapy調用請求
def parse_product_lines(self, response):
options = json.loads(response.body_as_unicode())
product_lines = options['products']
for product_line in product_lines:
payload = self.prepare_payload(product_line)
scrapy.Request('http://example.com',
method="POST",
body=urllib.urlencode(payload),
callback=self.parse_items)
def parse_items(self, response):
print response
,但請求未被執行。有人知道那裏發生了什麼嗎?
在循環結束時,我添加了return語句,一切都開始工作。 – tomgal