Remove <br> tags from a parsed Beautiful Soup list?

mamontazeri picture mamontazeri · May 8, 2011 · Viewed 22.4k times · Source

I'm currently getting into a for loop with all the rows I want:

page = urllib2.urlopen(pageurl)
soup = BeautifulSoup(page)
tables = soup.find("td", "bodyTd")
for row in tables.findAll('tr'):

At this point, I have my information, but the

<br />

tags are ruining my output.

What's the cleanest way to remove these?

Answer

Kabie picture Kabie · May 8, 2011
for e in soup.findAll('br'):
    e.extract()