I am working on Sentiment Analysis using The Reddit API Praw. My code is below:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import praw
from IPython import display
from nltk.sentiment.vader import SentimentIntensityAnalyzer as SIA
from pprint import pprint
import pandas as pd
import nltk
import seaborn as sns
import datetime
sns.set(style='darkgrid', context='talk', palette='Dark2')
reddit = praw.Reddit(client_id='XXXXXXXXXXX',
client_secret='XXXXXXXXXXXXXXXXXXX',
user_agent='StackOverflow')
headlines = set()
results = []
sia = SIA()
for submission in reddit.subreddit('bitcoin').new(limit=None):
pol_score = sia.polarity_scores(submission.title)
pol_score['headline'] = submission.title
readable = datetime.datetime.fromtimestamp(submission.created_utc).isoformat()
results.append((submission.title, readable, pol_score["compound"]))
display.clear_output()
Question A: With this code I can extract only the title of the text and so other few keys. I would like to extract everything in JSON format, but studying the documentation I haven't seen if it is possible.
If I call only submission in reddit.subreddit('bitcoin') It turn out only the id code. I would like to exctract everything, any information and save it in a JSON file.
Question B: How could I extract comments/messages from a specific day?