使用此xpath找不到数据?在Python Scrapy中

时间:2018-03-27 14:50:20

标签: python xpath scrapy

https://www.volkswagen-vans.co.uk/en/offers-finance/offers/caddy-panel-van.html

{
    "total_rows": 3,
    "offset": 0,
    "rows": [
        {
            "key": "ארץ",
            "id": "2017-09-01-09-05-11",
            "value": "Earth"
        },

        {
            "key": "בין",
            "id": "2015-01-19-11-30-28",
            "value": "between"
        },

        {
            "key": "שלום פיל",
            "id": "2018-01-30-18-04-11",
            "value": "Hello elephant"
        }

    ]
}

2 个答案:

答案 0 :(得分:0)

不是问题,而是你的(缺失)代码;在Chrome开发工具中 - >控制台,我明白了:

$x('//div[@class="vw_m108_item_container vw_accordion_item_container"]//div[@class="inner"]/div[@class="td"]//text()').length

输出:

84

当您在此处发布时,如@some-progammer所述,请始终发布您的代码。

请阅读MCVE

答案 1 :(得分:0)

我通过改变我的xpath来解决它。

response.xpath('//div[@class="vw_m108_item_container vw_accordion_item_container"][contains(@data-sectionname, "finance lease")]//div[@class="tr"]//text()')