I am trying to select the address of a company using XPath selectors, so that I can later insert it in my Spider in Scrapy. So, my goal is to extract the address, in this case only 'Address 123'. I now have to following XPath selector:
> response.xpath('//span[@property="streetAddress"]').get()
The output I get is as follows:
'<span class="partners__info-value" property="streetAddress">Address 123</span>'
Can anybody help me to select only 'Address 213'?? The html code is can be seen in the picture below.
HTML code
To extract the text Address 123 you need to use text() as follows:
text()
response.xpath('//span[@class="partners__info-value" and @property="streetAddress"]/text()')
2.1m questions
2.1m answers
60 comments
57.0k users