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, 2019 in Python by Reena
4,251 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, 2019 by Kailash
use 'href' instead of text

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
1,446 views
0 votes
1 answer

How to web scrape using python without using a browser?

Yes, you can use the headless mode. ...READ MORE

answered Apr 2, 2019 in Python by Yogi

edited Oct 7, 2021 by Sarfaraz 10,699 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, 2019 in Python by Kirti
1,210 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP