简体   繁体   English

Web 刮<span class="“b6a29bc0”" aria-label="“Baths”">python</span> <span class="“b6a29bc0”" aria-label="“Beds”">2、2</span>

[英]Web scraping python <span class=“b6a29bc0” aria-label=“Beds”>2</span>, <span class=“b6a29bc0” aria-label=“Baths”>2</span>

I've to pull the text content on below html code for python web scraping, issue is with class parameter all the three variables having same class parameter so i tried with arial-label that is not working. I've to pull the text content on below html code for python web scraping, issue is with class parameter all the three variables having same class parameter so i tried with arial-label that is not working.

2, 2、

3 3

Property_beds = response.css('.b6a29bc0::text').extract() Property_beds = response.css('.b6a29bc0::text').extract()

result getting both the variables"Beds","Baths", i want only single variable baths结果得到两个变量“床”,“浴室”,我只想要单变量浴室

'Property_beds': [2,3] 'Property_beds':[2,3]

But i want to include aria-label="Baths" in response.css(), i tried using below code but the output list is empty但我想在 response.css() 中包含 aria-label="Baths",我尝试使用以下代码,但 output 列表为空

Property_beds = response.css('span.b6a29bc0aria-label[attribute="Beds"]::text').extract() Property_beds = response.css('span.b6a29bc0aria-label[attribute="Beds"]::text').extract()

在此处输入图像描述

在此处输入图像描述

For single对于单身

Property_beds = response.css('span.b6a29bc0[aria-label=Beds]::text').extract()

for multiple nodes use css Or syntax:对于多个节点,使用 css 或语法:

response.css('span.b6a29bc0[aria-label=Beds], span.b6a29bc0[aria-label=Studio]').getall()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM