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
2,962 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

“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
• 57,530 points
122 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,080 points
83 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,040 points
317 views
+1 vote
1 answer

Not able to Import scikitplot package in my Jupyter Lab

To overcome this issue, you need to ...READ MORE

answered Feb 21, 2019 in Python by Yami
3,268 views
0 votes
1 answer
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
401 views
0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers