Reputation: 21
<a class="a-link-normal a-text-normal" href="/Art-Dutch-Republic-1585-Everyman/dp/0297833693/ref=sr_1_1?keywords=9780297833697&qid=1574351815&sr=8-1">
<span class="a-size-medium a-color-base a-text-normal">Art of the Dutch Republic 1585 - 1718 (Everyman Art Library)</span>
</a>
How to get Value of href using CSS selector or Xpath?
Upvotes: 1
Views: 1986
Reputation: 53
You can achieve this by following selector
a.your_calss_name::attr(href)
Upvotes: 0
Reputation: 807
Try this response.css('.a-link-normal ::attr(href)').extract()
Upvotes: 0
Reputation: 3561
CSS selectors example:
links = response.css("a.a-link-normal.a-text-normal::attr(href)").extract()
Upvotes: 0
Reputation: 3280
Here is an example:
def parse(self, response):
# iterate over all href
for href in response.xpath("//a[@class='class-name']/@href"):
# extract href as a string
url = href.extract()
Upvotes: 1