Quote:
Originally Posted by Maui
Is there an easy was to insert the attributes from a dictionary to the tag?
|
bs4 uses the default dictionary syntax for tag attributes.
E.g., you'd use the following code to add attributes:
Code:
new_tag = soup.new_tag('h1')
new_tag['class'] = 'invis big'
new_tag['id'] = 'page_i'
you could also manipulate the attrs property:
Code:
new_tag = soup.new_tag('h1')
new_tag.attrs = {'class': 'invis big', 'id': 'page_i'}