Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Soup('A')
#4
1.> soup('a') is not referring to a dictionary, but it's actually filtering and extracting all <a> tags from the parsed HTML, returning a ResultSet (a list-like object).
2.> The code tags = soup('a') assigns this list of Tag objects to the variable tags.
3.> When you print tags, it displays the representation of the ResultSet, which may look like a list.

Your understanding is correct: the square brackets indicate a list-like structure, but the actual content inside those brackets is a collection of Tag objects, not dictionary keys or values.
Reply


Messages In This Thread
Soup('A') - by new_coder_231013 - Aug-31-2022, 12:09 PM
RE: Soup('A') - by Larz60+ - Aug-31-2022, 12:23 PM
RE: Soup('A') - by new_coder_231013 - Sep-12-2022, 12:02 PM
RE: Soup('A') - by Gaurav_Kumar - Aug-09-2023, 11:49 AM
RE: Soup('A') - by Pubfonts - Aug-09-2023, 01:11 PM
RE: Soup('A') - by Pubfonts - Aug-10-2023, 09:24 AM
RE: Soup('A') - by Pubfonts - Aug-12-2023, 10:55 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020