Skip to content
Advertisement

How to scrape only a single href from a div class?

I would like to extract the content of the 1st <a href> from this <div>

JavaScript
JavaScript

I’m using BeautifulSoup and I’m also scraping some other contents from the same page and by using the following solution as result for abstract I’m having None

JavaScript
JavaScript

Is there a system to reach the first href by using something similar to 'a'[:1]?

Advertisement

Answer

You can select a list then slicing or use select_one as css selector to select single element as follows:

JavaScript

Oupput:

JavaScript
Advertisement