Created
July 28, 2018 23:29
-
-
Save Abrownn/bd47388910967925570c53ac6889c596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import praw | |
import sys | |
import urllib.parse | |
r = praw.Reddit(username = "", | |
password = "", | |
client_id = "", | |
client_secret = "", | |
user_agent = "checks the pushshift api for stolen comments due to spammers/scammers/whatever") | |
user = sys.argv[1] | |
urlbase = "http://api.pushshift.io/reddit/comment/search/?q=" | |
# get user comments | |
try: | |
user = r.redditor(user) | |
except: | |
print("User (%s) not found" % sys.argv[1]) | |
exit() | |
try: | |
comments = list(user.comments.new(limit=5)) | |
except: | |
print("User (%s) not found" % sys.argv[1]) | |
exit() | |
if len(comments) == 0: | |
print("Found 0 comments") | |
exit() | |
for x in comments: | |
print("\n--------------------------") | |
if len(x.body) >= 150: | |
temp = x.body[:150].rfind(" ") | |
else: | |
temp = 150 | |
#print("%d: (%s)" % (temp, x.body[:temp])) | |
search = urllib.parse.quote(x.body[:temp]) | |
url = urlbase + search | |
r = requests.get(url) | |
results = r.json() | |
print(x.body[:temp]) | |
print("\n-------------") | |
print("Found %d times" % (len(results['data']))) | |
for z in results['data']: | |
print("--- https://reddit.com/comments/%s/.../%s" % (z['link_id'][3:], z['id'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment