Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get href from an element from sibling class search?

I would like to get the href from the following html

<a class="AirQuality--detailsButton--DBdLS Button--primary--1UQTP" href="/en-IN/forecast/air-quality/l/bf01d09009561812f3f95abece23d16e123d8c08fd0b8ec7ffc9215c0154913c" target="_self">See Details</a>

where href to be extracted based on class class="AirQuality--detailsButton--DBdLS Button--primary--1UQTP" from element a.

I tried doing the following but not returning anything.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

response.css('a.AirQuality--detailsButton--DBdLS Button--primary--1UQTP::attr(href)').get()

Full html could be fetched through scrapy by

scrapy shell "https://weather.com/en-IN/weather/today/l/bf01d09009561812f3f95abece23d16e123d8c08fd0b8ec7ffc9215c0154913c"

Any help would be highly appreciated, thanks in advance 🙂

>Solution :

There are two class name . so you need to add dot(.) .Now it’s working.

response.css('a.AirQuality--detailsButton--DBdLS.Button--primary--1UQTP::attr(href)').get()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading