Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. import praw
  2. import pprint
  3. import csv
  4. import datetime
  5.  
  6. user_agent = "r/Polska worst karma checker"
  7. reddit = praw.Reddit(client_id='g4acurKhjufZFA', client_secret='XTwvIViikfGHv619wNDPGSVWPJ0', user_agent=user_agent, username='PolskaKarmaBot', password='lokomotywa123')
  8. subreddit = reddit.subreddit('polska')
  9.  
  10. with open('teczki.csv', 'w', newline='') as csvfile:
  11. writer = csv.writer(csvfile, delimiter=';')
  12. writer.writerow(['Id', 'Nazwa', 'Wynik', 'Data', 'Link'])
  13. index = 0
  14. skippedComments = 0
  15. totalComments = 0
  16. for submission in subreddit.submissions(None, 1506034105):
  17. submission.comments.replace_more(limit=0)
  18. comments = submission.comments.list()
  19. for comment in comments:
  20. totalComments += 1
  21. if hasattr(comment, 'score') and comment.score < 0 and comment.author is not None:
  22. print('Skipped ', skippedComments, ' comments!')
  23. skippedComments = 0
  24. permalink = comment.permalink()
  25. username = comment.author.name
  26. score = comment.score
  27. date = datetime.datetime.fromtimestamp(comment.created)
  28. writer.writerow([index, username, score, date, permalink])
  29. print(username, ' ', score, ' -> ', date)
  30. index += 1
  31. else:
  32. skippedComments += 1
  33.  
  34. with open('razem.txt', 'w', newline='') as razemfile:
  35. razemfile.write(str(totalComments) + ' komentarzy przeszukano')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement