79774361

Date: 2025-09-25 04:37:55
Score: 1.5
Natty:
Report link

As of Beautiful Soup 4.0.5 (released back in 2014), we now have PageElement.wrap(). See: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#wrap

Simple example:

from bs4 import BeautifulSoup
soup = BeautifulSoup("<body><a>Some text</a></body>")
soup.a.wrap(soup.new_tag("b"))
print(soup.body)
# <body><b><a>Some text</a></b></body>
Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Themis