本文整理汇总了Python中newspaper.Article.is_downloaded方法的典型用法代码示例。如果您正苦于以下问题:Python Article.is_downloaded方法的具体用法?Python Article.is_downloaded怎么用?Python Article.is_downloaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newspaper.Article
的用法示例。
在下文中一共展示了Article.is_downloaded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrap_newspaper
# 需要导入模块: from newspaper import Article [as 别名]
# 或者: from newspaper.Article import is_downloaded [as 别名]
def wrap_newspaper(self, web_page):
parser = NewspaperArticle(url=web_page.final_url)
parser.html = web_page.html
parser.is_downloaded = True
parser.parse()
return parser
示例2: MongoClient
# 需要导入模块: from newspaper import Article [as 别名]
# 或者: from newspaper.Article import is_downloaded [as 别名]
from newspaper import Article
client = MongoClient()
db_articles = client.news.articles
db_web_cache = client.news.web_cache
docs = db_articles.find()
for doc in docs:
print doc['_id']
if not doc['page']:
continue
url = doc['page']['urls'][0]
web_cache_doc = db_web_cache.find_one({'url': url})
if 'html_compressed' in web_cache_doc:
article = Article(url=url)
article.html = bz2.decompress(web_cache_doc['html_compressed'])
article.is_downloaded = True
article.parse()
doc['page']['text'] = article.text
print len(doc['page']['text'])
db_articles.save(doc)