[英]Scrapy request don't get parsed
我的所有請求均未得到解析。 它已成功解析。 這是我的代碼:
# -*- coding: utf-8 -*-
import scrapy
from boardgamegeek.items import BoardgamegeekItem
class TwoPlayersSpider(scrapy.Spider):
name = 'two_players'
start_urls = [
'https://www.boardgamegeek.com/xmlapi/geeklist/48970',
'https://www.boardgamegeek.com/xmlapi/geeklist/48986'
]
def parse(self, response):
bg_ids = ",".join(response.xpath("//item/@objectid").extract())
yield scrapy.Request("https://www.boardgamegeek.com/xmlapi/boardgame/{}".format(bg_ids), self.parse_bg)
def parse(self, response):
for bg in response.xpath("//boardgame").extract():
minplaytime = int(bg.xpath(".//minplaytime/text()").extract_first())
maxplaytime = int(bg.xpath(".//maxplaytime/text()").extract_first())
maxplayers = int(bg.xpath(".//maxplayers/text()").extract_first())
if (minplaytime <= 40 or maxplaytime <= 60) and maxplayers >= 3:
i = BoardgamegeekItem()
i["link"] = "http://www.boardgamegeek.com/boardgame/{}".format(bg.xpath(".//objectid").extract_first())
i["title"] = bg.xpath(".//name/text()").extract_first()
i["minplayers"] = int(bg.xpath(".//minplayers/text()").extract_first())
i["maxplayers"] = maxplayers
i["minplaytime"] = minplaytime
i["maxplaytime"] = maxplaytime
yield i
找到了! 發生這種情況是因為我有兩個名稱完全相同的解析函數! 我忘了將其中一個解析名稱更新為parse_bg
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.