Scrapy返回字典或可变项

时间:2019-05-03 03:31:02

标签: python scrapy

我不熟悉Scrap,我正在抓取一个站点,当我检查元素时会看到其属性值。

但是当我尝试将其提取时,例如名称:

当我尝试使用 extract_first 时:

{[property.name]}

当我使用提取时:

<h3 class="h5 listing-name text-truncate row-space-top-1" title="{[property.name]}" ng-bind="property.name">
                </h3>

这是我的代码:

    a_selectors = response.xpath("//div")
    a_selectors = a_selectors.xpath("//div")
    a_selectors = a_selectors.xpath("//div[@class='panel-image listing-img']")
    a_selectors = a_selectors.xpath("//a[@class='media-photo media-cover']/span/h3")

    print(str(len(a_selectors)))



    xpath_ = a_selectors[1].extract()
    print(str(xpath_))

    href_ = a_selectors[1].xpath('@href').extract_first()
    title_ = a_selectors[1].xpath('@title').extract_first()

代码仅是im如何访问元素的示例。当我使用extract()时,我正在获取元素。但我无法获得

是否可以从网站中提取属性值?例如,当我尝试获取 @title

时,所有这些都给了我{{property.name}}

0 个答案:

没有答案