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 6
6
import praw
7
7
8
8
9
- reddit = praw .Reddit ("BayesianMethodsForHackers" )
10
- subreddit = reddit .get_subreddit ("showerthoughts" )
11
9
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
+
13
19
14
20
n_sub = int ( sys .argv [1 ] ) if sys .argv [1 ] else 1
15
21
16
22
i = 0
17
23
while i < n_sub :
18
24
top_submission = next (top_submissions )
19
25
i += 1
20
-
21
26
top_post = top_submission .title
22
27
23
28
upvotes = []
26
31
27
32
for sub in top_submissions :
28
33
try :
29
- ratio = reddit . get_submission ( sub . permalink ) .upvote_ratio
34
+ ratio = sub .upvote_ratio
30
35
ups = int (round ((ratio * sub .score )/ (2 * ratio - 1 )) if ratio != 0.5 else round (sub .score / 2 ))
31
36
upvotes .append (ups )
32
37
downvotes .append (ups - sub .score )
You can’t perform that action at this time.
0 commit comments