浏览代码

Correctly handle HTML with no <body> tags.

tags/v0.2
Ben Kurtovic 10 年前
父节点
当前提交
3dde1c5d60
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. +4
    -0
      earwigbot/wiki/copyvios/parsers.py

+ 4
- 0
earwigbot/wiki/copyvios/parsers.py 查看文件

@@ -136,6 +136,10 @@ class HTMLTextParser(BaseTextParser):
except ValueError:
soup = bs4.BeautifulSoup(self.text).body

if not soup:
# No <body> tag present in HTML ->
# no scrapable content (possibly JS or <frame> magic):
return ""
is_comment = lambda text: isinstance(text, bs4.element.Comment)
for comment in soup.find_all(text=is_comment):
comment.extract()


正在加载...
取消
保存