使用Beautifulsoup去除特定标签 试用了Beautifulsoup,的确是个神器. 在抓取到网页时,会出现很多不想要的内容,例如<script>标签,利用beautifulsoup可以很容易去掉. soup = BeautifulSoup('<script>a</script>Hello World!<script>b</script>') [s.extract() for s in soup(‘script’)] soup Hello…
去除指定标签 from bs4 import BeautifulSoup #去除属性ul [s.extract() for s in soup("ul")] # 去除属性svg [s.extract() for s in soup("svg")] # 去除属性script [s.extract() for s in soup("script")] 去除注释 from bs4 import BeautifulSoup, Comment #去除注释…