Let's say I have the following page structure:
Within that structure I have the following nested structure:
I wrote
offers = response.xpath('//li[@class = "search-page__result"]')
to try and create an inerrable list. This part is successful, I believe, because if I say
for offer in offers:
print(offer.get())
then it will print out the HTML subsection as a string.
However if I say
for offer in offers:
features = offer.xpath('//ul[@class = "listing-key-specs"]')
the content of features
looks as if I would have used response
instead of offer
.
Does anyone have any guidance on how I can use xpath iteratively on each subsection of the structure at a time?
EDIT: I wanted to add this alternative solution that I found before my question was answered. As suggested here by YohanObadia, the below will work too:
for offer in offers:
features = Selector(text = offer.extract()).xpath('//ul[@class = "listing-key-specs"]')