【问题标题】:Finding the xpath of a class name with \n and spaces使用 \n 和空格查找类名的 xpath
【发布时间】:2019-06-17 16:32:31
【问题描述】:

这可能是一个简单的问题,我是新手。

我正在尝试获取此 div 中的数据

<div class="search-results-listings
        " vocab="http://schema.org/" typeof="SearchResultsPage">

response.xpath("//div[@class='search-results-listings\n']") 和 response.xpath("//div[@class='search-results-listings\n ']") 正在返回空数组

【问题讨论】:

    标签: xpath scrapy


    【解决方案1】:

    你可以使用XPathcontains

    response.xpath("//div[contains(@class, 'search-results-listings')]")
    

    【讨论】:

      猜你喜欢
      • 2017-06-05
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多