T
ted
Hi,
I'm using the BeautifulSoup module and having some trouble processing a
file. It's not printing what I'm expecting. In the code below, I'm expecting
cells with only "bgcolor" attributes to be printed, but I'm getting cells
with other attributes and some without any attributes.
Any help appreciated. Thanks,
Ted
import re
from BeautifulSoup import BeautifulSoup
text = open('yahoo.html').read()
soup = BeautifulSoup(text)
tables = soup('table', {'border':re.compile('.+')})
for table in tables:
cells = table.fetch('td', {'bgcolor':re.compile('.+')})
for cell in cells:
print cell
print "================"
I'm using the BeautifulSoup module and having some trouble processing a
file. It's not printing what I'm expecting. In the code below, I'm expecting
cells with only "bgcolor" attributes to be printed, but I'm getting cells
with other attributes and some without any attributes.
Any help appreciated. Thanks,
Ted
import re
from BeautifulSoup import BeautifulSoup
text = open('yahoo.html').read()
soup = BeautifulSoup(text)
tables = soup('table', {'border':re.compile('.+')})
for table in tables:
cells = table.fetch('td', {'bgcolor':re.compile('.+')})
for cell in cells:
print cell
print "================"