コード例 #1
0
ファイル: get_comments.py プロジェクト: smorin/pyhn
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import json
from hnapi import HackerNewsAPI

hn = HackerNewsAPI()
stories = hn.get_top_stories()

story = stories[0]
if not os.path.exists('comments.data'):
    comments = story.get_comments()
    open('comments.data', 'w').write(json.dumps(comments))
else:
    comments = json.load(open('comments.data'))
コード例 #2
0
ファイル: get_comments.py プロジェクト: nso-security/pyhn
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import json
from hnapi import HackerNewsAPI

hn = HackerNewsAPI()
stories = hn.getTopStories()

story = stories[0]
if not os.path.exists('comments.data'):
    comments = story.getComments()
    open('comments.data', 'w').write(json.dumps(comments))
else:
    comments = json.load(open('comments.data'))