长话短说,我试图用美丽的汤用强烈的标签取代b标签。 汤需要一些投入,包括美丽的汤find_all包装在一起,而不是单独的
<b>Words:</b> attributes
<b>Other Words:</b> other attributes
我有以下python3代码:
strong_tag = soup.new_tag("strong")
if(soup.find('b')):
for b_tag in soup.find_all('b'):
b_tag.wrap(strong_tag)
此输出
attributes
<strong><b>Words:</b><b>Other Words:</b></strong> other attributes
,而不是
<strong><b>Words:</b></strong> attributes
<strong><b>Other Words:</b></strong> other attributes
我如何 解决这个问题?
我假设一旦我能解决这个问题,我可以从b标签中提取()内容,只留下强标签。