github_hackernews_reddit_stars/gather_latest.py
2015-01-17 01:02:59 -05:00

20 lines
461 B
Python

from get_new_hn import hacker_news
from pymongo import MongoClient
import datetime
def get_new_hackernews():
client = MongoClient()
hn_data = hacker_news()
hn_db = client.githubs.hacker_news
inserted = 0
for hn in hn_data:
if not hn_db.find_one({'url': hn['url']}):
hn_db.insert(hn)
inserted += 1
print datetime.datetime.now(), "Inserted", inserted
if __name__ == '__main__':
get_new_hackernews()