Issue
I am trying to scrape some information from this website https://www.gumtree.co.za (https://www.gumtree.co.za/a-house-rentals-flat-rentals-offered/tamboerskloof/studio-flatlet-in-tamboerskloof/1005754794350910092234609 this is the link of the property I am taking information from); more specifically I am trying to take information from these span classes:
<div class="attribute">
<span class="name">Bathrooms (#):</span>
<span class="value">1</span>
</div>
I first want to check if the span class has Bathroom in it and then take the value for that. This is what I have right now:
bathrooms=response.xpath("//span[contains(text(),'Bathrooms')]/span[@class='value']text()").extract_first()
However, I do not get anything.
Any suggestions? Thank you!
Solution
This is the correct way to extract all the siblings. Bathrooms=response.xpath("//span[contains(text(),'Bathrooms')]/following-sibling::*").extract_first()
For more, you can refer to this: XPath Axes Hope this helps.
Answered By - aksr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.