Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import json
- import time
- from datetime import datetime
- users = set()
- bot = praw.Reddit(user_agent='',
- client_id='Iq6Y7YogHPtmbA',
- client_secret='',
- username='',
- password='')
- cnt = 0
- for submission in bot.subreddit('portugal').new(limit=None):
- if submission.author and not submission.author.name in users:
- users.add(submission.author.name)
- subs = set()
- for post in submission.author.submissions.new(limit=3):
- name = post.subreddit.display_name
- if name not in subs:
- print(submission.author.name + ">> " + str(post.created_utc) +
- " | " + name + " > " + post.title)
- subs.add(name)
- tosave = {
- "id": post.id,
- "author": submission.author.name,
- "score": post.score,
- "title": post.title,
- "name": name,
- "utc": str(datetime.utcfromtimestamp(post.created_utc)),
- "time": time.strftime("%Y%m%d-%H%M%S-%Z", time.localtime(post.created_utc))
- }
- with open(
- time.strftime("%Y%m%d-%H%M%S-%Z", time.localtime(post.created_utc)) + "-" +
- submission.author.name + ".crawl", 'w') as outfile:
- json.dump(tosave, outfile)
- outfile.write("\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement