东莞营销网站开发/新产品推广方案策划
答案很简单,可能会错过许多细微差别。如何,这应该让你知道如何去做,改善它。我相信这可以改进,但你应该能够在文档的帮助下快速完成。
from bs4 import BeautifulSoup
doc = ['
'
Page title','
This is paragraph one.',
'
This is paragraph two.',
'']
soup = BeautifulSoup(''.join(doc))
for tag in soup.findAll('script'):
# Use extract to remove the tag
tag.extract()
# use simple insert
soup.body.insert(len(soup.body.contents), tag)
print soup.prettify()
输出:
Page title
This is paragraph
one
.
This is paragraph
two
.
document.write("Hello World!")