How do I insert an attribute using BeautifulSoup?
For example, insert border="1" as a <table> tag attribute.
EDIT:
I’ve answered my own question (for a particular class of table, even):
inTopic = urllib2.urlopen("file:///C:/test/test.html")
content = BeautifulSoup(inTopic)
tlist = content.findAll('table', "myTableClass")
for tbl in tlist:
tbl['border'] = "1"
print tbl.attrs
How about:
Do not forget to try
lxml.html, it’s fast and parse well.