I am using python + BeautifulSoup to parse an HTML document.
Now I need to replace all elements in an HTML document, wit
From BeautifulSoup docs
from BeautifulSoup import BeautifulSoup, Tag soup = BeautifulSoup("TEXTHERE") tag = Tag(soup, "h1", [("class", "someclass")]) tag.insert(0, "TEXTHERE") soup.h2.replaceWith(tag) print soup # TEXTHERE