[英]CSS Selector / XPath needed for accessing a <span>
I'm doing a scrapy project in which I try to extract data on sponsored TripAdvisor listings ( https://www.tripadvisor.com/Hotels-g189541-Copenhagen_Zealand-Hotels.html ).我正在做一个 scrapy 项目,在该项目中我尝试提取有关赞助的 TripAdvisor 列表的数据( https://www.tripadvisor.com/Hotels-g189541-Copenhagen_Zealand-Hotels.AFC35FDC70D25FC789 )
This is how the html code looks like这就是 html 代码的样子
<div class="listing_title ui_columns is-gapless is-mobile is-multiline">
<div class="ui_column is-narrow">
<span class="ui_merchandising_pill sponsored_v2">Sponsored</span>
</div>
<div class="ui_column is-narrow title_wrap">
<a target="_blank" href="/Hotel_Review-g189541-d206753-Reviews-Scandic_Front-Copenhagen_Zealand.html" id="property_206753" class="property_title prominent " data-clicksource="HotelName" onclick="return false;" dir="ltr"> Scandic Front</a>
</div>
</div>
I was able to successfully retrieve elements such as the link, id, name with constructs such as .css(".listing_title").css("a::text").extract()
.我能够使用.css(".listing_title").css("a::text").extract()
等结构成功检索链接、id、名称等元素。 However, I have trouble retrieving anything from the tag.但是,我无法从标签中检索任何内容。 I always receive the following error:我总是收到以下错误:
AttributeError: 'SelectorList' object has no attribute 'exctract' AttributeError: 'SelectorList' object 没有属性 'exctract'
What can I do?我能做些什么?
It looks like you have a typo, try changing .exctract
to .extract
, you have an extra c
.看起来你有一个错字,尝试将.exctract
更改为.extract
,你有一个额外的c
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.