本文整理汇总了Python中Search.search_for_showhn方法的典型用法代码示例。如果您正苦于以下问题:Python Search.search_for_showhn方法的具体用法?Python Search.search_for_showhn怎么用?Python Search.search_for_showhn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search.search_for_showhn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Connection
# 需要导入模块: import Search [as 别名]
# 或者: from Search import search_for_showhn [as 别名]
#
# creates a new mongodb database with the first thousand
# and last thousand posts that the queries "show hn" and "showhn" find
# in collection 'posts'
#
import Search
from pymongo import Connection
import pymongo
if __name__ == '__main__':
connection = Connection("mongodb://root:[email protected]:12015")
db = connection['showhn']
posts = Search.search_for_showhn()
effort = 0
bool = True
while (bool):
posts_collection = db['posts']
effort += 1
try:
posts_collection.insert(posts,safe=True)
bool = False
except pymongo.errors.OperationFailure:
posts_collection.drop()
bool = True
print effort