I am trying to scrape posts from a subreddit (vim)then generate a CSV, however, I want to get the data only for a period of (1/2020 -- 3/2020).
I don't know how to set this time limit in my code. I set the posted limit to 2000 however, it's only for the past 2 days.
In the following I put my code, I really appreciate your kindest support in advance:
import praw
import pandas as pd
#creating an instance of Reddit.
reddit = praw.Reddit(client_id = 'XXXXX',
client_secret ='XXXXXX',
user_agent='XXXX')
#scrape data from the vim subreddit
posts = reddit.subreddit('vim').hot(limit = 2000)
#specifying raw & columns
c = ['title', 'name', 'url', 'score', 'locked', 'created', 'num of comment', 'upvote ratio']
df = pd.DataFrame(([post.title, post.name, post.url, post.score, post.locked, post.created, post.num_comments, post.upvote_ratio] for post in posts), columns=c)
#creating CSV
df.to_csv('vim_subreddit.csv')