我希望在新闻文章的引文之间提取文本。为此目的,第一步涉及提取新文章。然后在第二步中使用正则表达式来获取引用。我不确定但是当我编码成ascii时引用会丢失。有办法解决这个问题吗?
from goose import Goose
from requests import get
response = get('http://www.nytimes.com/2015/05/19/health/study-finds-dense-breast-tissue-isnt-always-a-high-cancer-risk.html?src=me&ref=general')
extractor = Goose()
article = extractor.extract(raw_html=response.content)
text = article.cleaned_text
encode_text=text.encode('ascii','ignore')
comments=re.findall('"([^"]*)"', encode_text)
print comments