Issue
From: https://www.funda.nl/en/koop/veenendaal/huis-42657821-roggeveld-59/ I want to select the living area and plot size through CSS selector.
Therefore, I have found the following css path:
response.css('span.kenmerken-highlighted__value.fd-text--nowrap').xpath('normalize
space()')
When I do this, i get the following output:
[<Selector xpath='normalize-space()' data='123 m²'>, <Selector xpath='normalize-space()' data='187 m²'>, <Selector xpath='normalize-space()' data='4'>]
This is because multiple values on the website have the same css path. What do I have to do if I want to specify for example the 187 m2, or the '4'?
Solution
Try the below xpath selectors
>>> response.xpath("//*[@title='plot size']/following-sibling::span[1]/text()").get()
'187 m²'
>>> response.xpath("//*[@title='bedrooms']/following-sibling::span[1]/text()").get()
'4'
For css selectors you can use the below
>>> response.css("[title='plot size'] + span ::text").get()
'187 m²'
>>> response.css("[title='bedrooms'] + span ::text").get()
'4'
Answered By - msenior_
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.