Arjun Arun
Arjun Arun

Reputation: 313

Python - Extracting name of href hyperlink

I'm using Python to extract data from a webpage. The webpage has many anchor tags that have href attributes.

For example:

<a class="identifier" href="/ICD10CM/Codes/A00-B99/A15-A19/A18-/A18.17">A18.17</a>

I am able to extract these specific tags by using

for x in soup.find_all('a'): print(x)

However, I only want to extract the name of the link (A18.17 in the example). How can I do this?

Thanks.

Upvotes: 0

Views: 464

Answers (1)

imacoder
imacoder

Reputation: 186

print x.text

There is a similar question answered here and documentation should help.

Upvotes: 2

Related Questions