Advertisement
Guest User

Username Scrape

a guest
Nov 21st, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. import praw
  2.  
  3. #Reddit instance
  4. reddit = praw.Reddit(client_id='XXXXXXXXXXXX',
  5.                     client_secret='XXXXXXXXXXXX',
  6.                     password='XXXXXXXXXXXXX',
  7.                     user_agent='UNameCollectorStudy',
  8.                     username='gcf16')
  9.  
  10. #Request user enter session ID
  11. sub_name = input('Which Sub are we looking at today?  >')
  12. with open ('output.csv', 'a') as f:
  13.     f.write('Today\'s Date and Time on ' + sub_name)
  14.     f.write('\n')
  15.     f.write('\n')
  16.  
  17. x = 0
  18. while x == 0:
  19.     session_id = input('Enter session ID   >')
  20.  
  21. # Fetch thread contents where submission_id is found
  22.     thread = reddit.submission(id=session_id)
  23.  
  24. #create list to store usernames
  25.     authors = []
  26.  
  27. #Add authors to CSV
  28.     with open ('output.csv', 'a') as f:
  29.         for each in thread.comments.list():
  30.             authors.append(each.author)
  31.             f.write(str(each.author))
  32.             f.write('\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement