How to get all anchor tags using BeautifulSoup?

0 votes

Hi. I am web scraping and I am trying to find all the anchor tags in the page. I am using the following:

for link in soup.find(‘a’):
   print (a.text)

But some times the loop fails. Is there any other way to do it?

Apr 2 in Python by Reena
24 views

1 answer to this question.

0 votes

Yes, you can do it by using the default option by BeautifulSoup.

Try this:

for tag in soup.find_all('a'):
    print (tag.text)
answered Apr 2 by Kailash

Related Questions In Python

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to get text label from SAP using pywinauto[python]

Hi. Can you please tell me what ...READ MORE

answered Jun 28, 2018 in Python by Nietzsche's daemon
• 4,260 points
270 views
0 votes
1 answer

How to parse html file to BeautifulSoup?

Hey. Refer to the following code: driver.get("link") html = ...READ MORE

answered Apr 2 in Python by Kirti
16 views
0 votes
1 answer