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 in Python by Sowmya
77 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 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
• 56,160 points
41 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 in Python by Anirudh
• 2,060 points
27 views
0 votes
1 answer

Not able to take input in python

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

answered Jan 31 in Python by Omkar
• 67,140 points
26 views
0 votes
1 answer

Not able to Import scikitplot package in my Jupyter Lab

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

answered Feb 21 in Python by Yami
332 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
0 votes
2 answers