本文整理汇总了Python中Analyzer.Analyzer.get_poem_detail方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.get_poem_detail方法的具体用法?Python Analyzer.get_poem_detail怎么用?Python Analyzer.get_poem_detail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.get_poem_detail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: poem_detail_crew
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import get_poem_detail [as 别名]
def poem_detail_crew(self):
# update urls set analyzed = 1 where url = 'http://www.haoshiwen.org/view.php?id=9510'
# 一条一条取
total_count = 10
c = 1
while c < total_count:
c += 1
continue
# 去除诗词的详情页url
url = self.db.select_unanalyzed_url(2)
if url is not None:
url = url['url']
# 判断是否抓取过
if not self.db.poem_exists(url):
content = Downloader.get_html(url, 'poem')
if content:
try:
poem = Analyzer.get_poem_detail(content, url)
if poem:
# 分析成功,入库
poem_content = poem[0]
poem_info = poem[1]
self.db.insert_poem(poem_content)
self.db.insert_infomations(url, 1, poem_info)
self.db.update_url(url)
print "%d/%d %s %s" % (c, total_count, poem_content['title'], poem_content['url'])
else:
self.db.insert_error('analyze_poem_detail_error', 5, 'reason', url)
except Exception, e:
continue
else:
self.db.insert_error('get_poem_detail_error', 4, 'reason', url)
else:
self.db.update_url(url)
else:
count = total_count