Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import pprint
- import csv
- import datetime
- user_agent = "r/Polska worst karma checker"
- reddit = praw.Reddit(client_id='g4acurKhjufZFA', client_secret='XTwvIViikfGHv619wNDPGSVWPJ0', user_agent=user_agent, username='PolskaKarmaBot', password='lokomotywa123')
- subreddit = reddit.subreddit('polska')
- with open('teczki.csv', 'w', newline='') as csvfile:
- writer = csv.writer(csvfile, delimiter=';')
- writer.writerow(['Id', 'Nazwa', 'Wynik', 'Data', 'Link'])
- index = 0
- skippedComments = 0
- totalComments = 0
- for submission in subreddit.submissions(None, 1506034105):
- submission.comments.replace_more(limit=0)
- comments = submission.comments.list()
- for comment in comments:
- totalComments += 1
- if hasattr(comment, 'score') and comment.score < 0 and comment.author is not None:
- print('Skipped ', skippedComments, ' comments!')
- skippedComments = 0
- permalink = comment.permalink()
- username = comment.author.name
- score = comment.score
- date = datetime.datetime.fromtimestamp(comment.created)
- writer.writerow([index, username, score, date, permalink])
- print(username, ' ', score, ' -> ', date)
- index += 1
- else:
- skippedComments += 1
- with open('razem.txt', 'w', newline='') as razemfile:
- razemfile.write(str(totalComments) + ' komentarzy przeszukano')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement