-
Notifications
You must be signed in to change notification settings - Fork 0
/
redditkoolgax.py
36 lines (28 loc) · 1.16 KB
/
redditkoolgax.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import praw
import pandas as pd
import datetime as dt
reddit = praw.Reddit(client_id='ur_client_id', \
client_secret='ur_client_secret', \
user_agent='ur_user_agent', \
username='ur_username', \
password='ur_password')
subreddit = reddit.subreddit('learnpython')
top_subreddit = subreddit.top(limit = 15)
topics_dict = { "title":[], \
"score":[], \
"id":[], "url":[], \
"comms_num": [], \
"created": [], \
"body" : []}
for submission in top_subreddit:
topics_dict["title"].append(submission.title)
topics_dict["score"].append(submission.score)
topics_dict["id"].append(submission.id)
topics_dict["url"].append(submission.url)
topics_dict["comms_num"].append(submission.num_comments)
topics_dict["created"].append(submission.created)
topics_dict["author"].append(submission.author)
topics_dict["body"].append(submission.selftext)
topics_data = pd.DataFrame(topics_dict)
topics_data.to_csv('koolgax.csv', index = False)
topics_data.to_excel(r'C:\Users\Nihar Sanda\Desktop\koolgax.xlsx')