我想使用在这里https://github.com/miso-belica/jusText找到的 jusText 实现从 html 页面中获取干净的内容。基本上它是这样工作的:
import requests
import justext
response = requests.get("http://planet.python.org/")
paragraphs = justext.justext(response.content, justext.get_stoplist("English"))
for paragraph in paragraphs:
if not paragraph.is_boilerplate:
print paragraph.text
我已经下载了我想使用这个工具解析的页面(其中一些不再在线提供),我从中提取了 html 内容。由于 jusText 似乎只处理请求的输出(这是一个响应类型对象),我想知道是否有任何自定义方法可以将响应对象的内容设置为包含我想要解析的 html 文本。