I'm trying to extract information from a large webpage using Beautiful Soup 4. The information I want is contained within one particular div, which I can extract without problem:
passage = soup.find("div", class_="desired_div")
I then want to add tags before the extracted part of the tree - e.g. I want to wrap the extracted div with another div - in preparation for outputing the extracted info as another html file.
With BS4, how do I insert tags before the extracted portion of the parse tree, or wrap the extracted portion of the parse tree? BS4 seems to only allow me to operate on the children of the extracted div (as per the documentation), but I want to insert before or wrap the extracted div.