Reputation:
I want to display http:///gb/groceries/easter-essentials--%28approx-205kg%29
.
In scrapy
I used this XPath expression:
response.xpath('//div[@class="productNameAndPromotions"]/h3/a/href').extract()
but it didn't work!
<div class="product ">
<div class="productInfo">
<div class="productNameAndPromotions">
<h3>
<a href="http:///gb/groceries/easter-essentials--%28approx-205kg%29">
<img src="http:co.uk/wcsstore7.20.1.145/ExtendedSitesCatalogAssetStore/image/catalog/productImages/08/020000008_L.jpeg" alt="" />
</a>
</h3>
</div>
</div>
</div>
Upvotes: 1
Views: 1902
Reputation: 52685
This //div[@class="productNameAndPromotions"]/h3/a/href
means you want to get element href
which is child of a
.
If you want to extract nodes' attribute, e.g. href
, you need to use @attribute
syntax. Try below:
//div[@class="productNameAndPromotions"]/h3/a/@href
Upvotes: 1