I'm using Scrapy library to crawl a webpage.
But I have a problem. I do not know how to target data
attribute.
I have an link with data
attribute and href
as follows:
<a data-item-name="detail-page-link" href="this-is-some-link">
What I want is the value of href
. If a
had class I could do it as follows:
response.css('.some-class::attr(href)')
But the problem is that I do not know how to target data-item-name
attribute.
Any advice?
I'm not sure, if you can do this with the
css
method, but with thexpath
method you should be able to do:Using scrapy
css
selector, you can do :