BeautifulSoup Not able to extract multiple tags in a class

0 votes

I am trying to extract 2 tags, but I am not able to.

I tried the following to get 1 tag:

for tag in soup.find_all('a'):
    print (tag.text)

But when I try this for 2 tags, it doesn't work.

for tag in soup.find_all('a','div'):
    print (tag.text)
Apr 2, 2019 in Python by Sowmya
6,905 views

1 answer to this question.

0 votes

You are missing the square braces. You have to pass an array. Try this:

for tag in soup.find_all(['a','div']):
    print (tag.text)
answered Apr 2, 2019 by Firoz

Related Questions In Python

0 votes
1 answer

How to extract specific tags in multiple html .txt files using python.

Hello, @Pooja, Even I got the same issue, ...READ MORE

answered Aug 5, 2020 in Python by Kedaar Thomas
5,255 views
0 votes
1 answer

“stub” __objclass__ in a Python class how to implement it?

You want to avoid interfering with this ...READ MORE

answered Sep 27, 2018 in Python by Priyaj
• 58,100 points
2,320 views
0 votes
0 answers

How to implement multiple try codes in a single block using Python?

Hi all, As per the title, I am ...READ MORE

Jan 14, 2019 in Python by Anirudh
• 2,090 points
639 views
0 votes
1 answer

Not able to take input in python

You are using python 2 in which ...READ MORE

answered Jan 31, 2019 in Python by Omkar
• 69,220 points
3,627 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 13,020 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,894 views
0 votes
1 answer
0 votes
1 answer
+1 vote
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP