View Single Post
Old 09-11-2010, 01:24 PM   #2688
TonytheBookworm
Addict
TonytheBookworm is on a distinguished road
 
TonytheBookworm's Avatar
 
Posts: 264
Karma: 62
Join Date: May 2010
Device: kindle 2, kindle 3, Kindle fire
Quote:
Originally Posted by Starson17 View Post
item and mydaddy are BeautifulSoup Tag objects. Each Tag object has a specified list of properties. mydaddy is the parent of item. The name of mydaddy is 'div'. mydaddy has an attribute called 'id'. The value of that attribute is 'MainContent'.

You can access a tag's attributes by treating the Tag object as though it were a dictionary. Thus you want:
Code:
if mydaddy['id'] == 'MainContent'
  .......
or

Code:
if mydaddy.has_key('id') and mydaddy['id'] == 'MainContent'
  .......
Thank you for explaining that to me.
TonytheBookworm is offline