File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Chapter4_TheGreatestTheoremNeverTold Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 66import praw
77
88
9- reddit = praw .Reddit ("BayesianMethodsForHackers" )
10- subreddit = reddit .get_subreddit ("showerthoughts" )
119
12- top_submissions = subreddit .get_top (limit = 100 )
10+ #subreddit = reddit.get_subreddit("showerthoughts")
11+
12+ #top_submissions = subreddit.get_top(limit=100)
13+
14+ #update old praw usage to current version (7.6.0)
15+ #please notice that new Reddit Object usage, especially the praw.ini file
16+ reddit = praw .Reddit ("BayesianMethodsForHackers" ,user_agent = "BMFH" )
17+ top_submissions = reddit .subreddit ("showerthoughts" ).new (limit = 100 )
18+
1319
1420n_sub = int ( sys .argv [1 ] ) if sys .argv [1 ] else 1
1521
1622i = 0
1723while i < n_sub :
1824 top_submission = next (top_submissions )
1925 i += 1
20-
2126top_post = top_submission .title
2227
2328upvotes = []
2631
2732for sub in top_submissions :
2833 try :
29- ratio = reddit . get_submission ( sub . permalink ) .upvote_ratio
34+ ratio = sub .upvote_ratio
3035 ups = int (round ((ratio * sub .score )/ (2 * ratio - 1 )) if ratio != 0.5 else round (sub .score / 2 ))
3136 upvotes .append (ups )
3237 downvotes .append (ups - sub .score )
You can’t perform that action at this time.
0 commit comments