Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. import praw
  2. import sqlite3
  3. import sys
  4.  
  5. user_agent='An agent that checks for false history on /r/history created by /u/iNeverQuiteWas'
  6. app_id='MB4QincWfYR1iA'
  7. app_secret='tBvwCiogH-AnlaWcotUgqQJncf4'
  8. app_uri='https://127.0.0.1:65010/authorize_callback'
  9. app_scopes='account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modothers modposts modself modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread'
  10. refresh_token='66260905-jQkoEyNJIQJ1pO9TnQ50DYs6EBc'
  11.  
  12. data = sqlite3.connect('skinCare.db')
  13. cur = data.cursor()
  14. cur.execute('CREATE TABLE IF NOT EXISTS scanned(id TEXT)')
  15. data.commit()
  16.  
  17. master = {}
  18.  
  19. def login():
  20.     print('Logging in to Reddit as /u/History-Checker-Bot...')
  21.     r=praw.Reddit(user_agent)
  22.     r.set_oauth_app_info(app_id,app_secret,app_uri)
  23.     r.refresh_access_information(refresh_token)
  24.     print('Finished logging in...')
  25.     return r
  26.  
  27. r = login()
  28.  
  29. def search(ids=sys.argv[1]):
  30.     post = r.get_submission(submission_id=ids)
  31.     post.replace_more_comments(limit=None, threshold=0)
  32.     all_comments = post.comments
  33.     user_count = 0
  34.     for comment in all_comments:
  35.         author = comment.author.name
  36.         cur.execute('SELECT * FROM scanned WHERE id=?',[comment.id])
  37.         if not cur.fetchone():
  38.             user_count+=1
  39.             cur.execute('INSERT INTO scanned VALUES (?)',[comment.id])
  40.     master[author] = user_count
  41.  
  42.  
  43. print(master)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement