In [2]:
from __future__ import print_function
In [3]:
from hackernews import HackerNews
hn = HackerNews()
In [29]:
show_hn_ids = hn.show_stories()
print(len(show_hn_ids), "total Show HN ids")
#
show_hn_stories = []
for sid in show_hn_ids:
show_hn_stories.append(hn.get_item(sid))
In [31]:
show_hn_github_repos = [item for item in show_hn_stories
if item.url is not None
and 'github.com' in item.url
and 'gist' not in item.url]
print(len(show_hn_github_repos), "Show HN stories from github")
print('\n'.join([item.title for item in show_hn_github_repos
if item in hn_github_repos]))
In [5]:
new_hn_ids = hn.new_stories()
print(len(new_hn_ids), "total HN ids")
all_hn_items = []
for sid in new_hn_ids:
all_hn_items.append(hn.get_item(sid))
In [22]:
hn_github_repos = [item for item in all_hn_items
if item.url is not None
and 'github.com' in item.url
and 'gist' not in item.url]
In [24]:
print(len(hn_github_repos), "total github repos", '\n')
print('\n\n'.join
(
item.title+'\n'+item.url
for item in hn_github_repos
)
)
In [25]:
dir(hn_github_repos[1])
Out[25]:
In [34]:
a = hn_github_repos[1]
b = show_hn_github_repos[1]
x = a
print(x.item_id,
x.item_type,
x.parts,
x.raw,
x.score,
x.submission_time,
x.text,
x.title,
x.url,
sep='\n')
In [ ]: