简体   繁体   中英

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.

2,

3

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

result getting both the variables"Beds","Baths", i want only single variable baths

'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

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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