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
18 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,120 points
28 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,050 points
18 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
• 65,850 points
19 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
152 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
10 views
0 votes
1 answer
0 votes
2 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.