File tree 3 files changed +29
-0
lines changed
3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 53
53
## Cellular Automata
54
54
* [ Conways Game Of Life] ( https://github.com/TheAlgorithms/Python/blob/master/cellular_automata/conways_game_of_life.py )
55
55
* [ Game Of Life] ( https://github.com/TheAlgorithms/Python/blob/master/cellular_automata/game_of_life.py )
56
+ * [ Nagel Schrekenberg] ( https://github.com/TheAlgorithms/Python/blob/master/cellular_automata/nagel_schrekenberg.py )
56
57
* [ One Dimensional] ( https://github.com/TheAlgorithms/Python/blob/master/cellular_automata/one_dimensional.py )
57
58
58
59
## Ciphers
987
988
* [ Fetch Jobs] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/fetch_jobs.py )
988
989
* [ Get Imdb Top 250 Movies Csv] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdb_top_250_movies_csv.py )
989
990
* [ Get Imdbtop] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdbtop.py )
991
+ * [ Get Top Hn Posts] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_top_hn_posts.py )
990
992
* [ Get User Tweets] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_user_tweets.py )
991
993
* [ Giphy] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/giphy.py )
992
994
* [ Instagram Crawler] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_crawler.py )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ sklearn
14
14
statsmodels
15
15
sympy
16
16
tensorflow
17
+ texttable
17
18
tweepy
18
19
types-requests
19
20
xgboost
Original file line number Diff line number Diff line change
1
+ from __future__ import annotations
2
+
3
+ import requests
4
+
5
+
6
+ def get_hackernews_story (story_id : str ) -> dict :
7
+ url = f"https://hacker-news.firebaseio.com/v0/item/{ story_id } .json?print=pretty"
8
+ return requests .get (url ).json ()
9
+
10
+
11
+ def hackernews_top_stories (max_stories : int = 10 ) -> list [dict ]:
12
+ """
13
+ Get the top max_stories posts from HackerNews - https://news.ycombinator.com/
14
+ """
15
+ url = "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
16
+ story_ids = requests .get (url ).json ()[:max_stories ]
17
+ return [get_hackernews_story (story_id ) for story_id in story_ids ]
18
+
19
+
20
+ def hackernews_top_stories_as_markdown (max_stories : int = 10 ) -> str :
21
+ stories = hackernews_top_stories (max_stories )
22
+ return "\n " .join ("* [{title}]({url})" .format (** story ) for story in stories )
23
+
24
+
25
+ if __name__ == "__main__" :
26
+ print (hackernews_top_stories_as_markdown ())
You can’t perform that action at this time.
0 commit comments