Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #this file was used to get the most recent 1000 posts and comments from drug and recovery subreddits in updated_reddit_forum_categories
- # this set of users were labelled as level 1
- #original posters and comment authors both were collected
- import pprint
- import updated_reddit_forum_categories
- drug_subreddits = updated_reddit_forum_categories.drug_subreddits
- recovery_subreddits = updated_reddit_forum_categories.recovery_subreddits
- import pymongo
- client = pymongo.MongoClient('130.212.215.135', 27017)
- db = client.new_reddit
- collection = db.user_post_history_level_1_users
- collection2 = db.subreddits_done
- done_subreddits = collection2.distinct("subreddit")
- import praw
- my_user_agent = "sfsuthesis1"
- my_client_id = "719oiPs6Hm2YAA"
- my_client_secret = "dIwlDy7TYQlxJGkCHoyrVK2suqg"
- my_username = "sfsuthesis"
- my_password = "sfsuthesis"
- reddit = praw.Reddit(user_agent=my_user_agent,
- client_id=my_client_id,
- client_secret=my_client_secret)
- reddit = praw.Reddit(user_agent=my_user_agent,
- client_id=my_client_id,client_secret=my_client_secret,
- username=my_username,
- password=my_password)
- for c,subreddit in enumerate(recovery_subreddits):
- if subreddit in done_subreddits:
- continue
- collection2.insert({"subreddit":subreddit})
- print c, subreddit
- sub = reddit.subreddit(subreddit)
- posts = sub.new(limit=None)
- count=0
- for submission in posts:
- count = count +1
- print count
- # print submission.author
- post_author = str(submission.author)
- # print post_author
- # collection.insert({"redditor":post_author})
- # print submission.selftext
- # print submission.title
- # print submission.id
- submission.comments.replace_more(limit=0)
- for comment in submission.comments.list():
- # print comment.body
- # print comment.author
- comment_author = str(comment.author)
- # collection.insert({"redditor":comment_author})
- # print comment.id
- # print "******************"
- # print "**************"
- #do thing to each submission
- # user = reddit.redditor("Jtgivesualadyboner")
- # submissions = user.submissions
- #
- # for p in submissions.new(limit=None):
- # print p.title
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement