In [328]:
import os
import random
import requests
import re
import json
import praw
In [329]:
#os.chdir('~/.rgd')
In [330]:
r = praw.Reddit(user_agent='rgdsnatch')
In [331]:
r.login('artcontrol', 'zipit123')
In [332]:
usrd = r.get_my_subreddits()
In [333]:
suls = []
In [334]:
for subs in usrd:
print subs
suls.append(subs)
In [335]:
suls
Out[335]:
In [336]:
lesuls = len(suls)
ransuz = random.randint(0, lesuls)
thesubraz = suls[ransuz]
In [337]:
suls
Out[337]:
In [338]:
print thesubraz
In [339]:
rd = r.get_subreddit('redditgetsdrawn')
In [340]:
rdnewz = rd.get_new()
In [341]:
rdnew = []
In [342]:
rdnew
Out[342]:
In [343]:
for uz in rdnewz:
#print uz
rdnew.append(uz)
In [344]:
rdnew
Out[344]:
In [345]:
ransubz = random.randint(0,24)
In [346]:
print ransubz
In [347]:
ransev = rdnew[ransubz]
In [348]:
rgdautoz = str(ransev.author)
In [349]:
rgdsubred = str(ransev.subreddit)
In [350]:
sutit = ('[' + rgdsubred + ']')
In [351]:
sutit
Out[351]:
In [352]:
rgdaqwew = ('xpost[RGD]' + rgdautoz)
In [353]:
rgdaturo = str(ransev.url)
In [354]:
rgdatit = str(ransev.title)
In [355]:
rgdatit
Out[355]:
In [324]:
#rd.get_top
In [325]:
linkdict = {}
In [326]:
ophtml = open('index.html', 'a')
In [327]:
ls
In [274]:
ady = r.get_subreddit('artcontroldrawsyou')
In [275]:
comrgd = rgdatit + ' ' + rgdaturo
In [276]:
comrgd
Out[276]:
In [277]:
import time
In [278]:
loctime = time.localtime()
In [279]:
loctime.tm_mday
Out[279]:
In [280]:
loctime.tm_mon
Out[280]:
In [281]:
thedat = (str(loctime.tm_mday) + '/' + str(loctime.tm_mon))
In [282]:
thedat
Out[282]:
In [283]:
mixtut = (thedat + sutit + rgdautoz)
In [284]:
loctime
Out[284]:
In [285]:
ady.submit(mixtut , (rgdaqwew, comrgd))
Out[285]:
In [286]:
#print str(newa.title)
In [287]:
import json
In [288]:
newzjson = json.dumps(linkdict)
In [289]:
#newzjson
In [289]:
In [290]:
rmine = r.get_redditor('itwillbemine')
In [291]:
#opest = open('userurl.json', 'r')
#opest.read()
#opest.close()
In [292]:
mincom = rmine.get_comments()
In [293]:
#print mincom
In [ ]:
minels = []
In [ ]:
dausr = {}
In [ ]:
for newa in rdnew:
#rint newa.url
#print newa.author
linkdict.update({str(newa.author): str(newa.url)})
In [ ]:
for con in mincom:
#print con.body
minels.append(con)
dausr.update({str(con.id): str(con.body)})
In [ ]:
minels
In [ ]:
noizjson = json.dumps(dausr)
In [ ]:
newposts = open('userurl.json', 'a')
newposts.write(newzjson)
print ('file userurl.json updated')
newcomments = open('idcomt.json', 'a')
newcomments.write(noizjson)
print ('user comments updated')
newposts.close()
newcomments.close()
In [ ]:
rdusr = str(con.author)
In [ ]:
minelsz = []
In [ ]:
In [ ]:
#for mina in minels:
#print mina.body
# minelsz.append(mina.body)
In [ ]:
#minelsz
In [ ]:
#mina.body
In [ ]: