Get Drawn
A python script for reddit
In [1]:
x = 'hello ther!'
In [2]:
mylist = []
In [3]:
mylist.append('testing adding this to the list!')
In [4]:
mylist
Out[4]:
In [5]:
mylist.append()
In [6]:
import os
import random
import bs4
import requests
import re
import json
In [7]:
import praw
In [8]:
r = praw.Reddit(user_agent='redditgetsdrawn blog post')
In [9]:
rd = r.get_subreddit('redditgetsdrawn')
In [10]:
rd.url
Out[10]:
In [11]:
rd.created
Out[11]:
In [12]:
subls = []
In [13]:
subrd = rd.subscribers
subls.append(subrd)
In [14]:
subls
Out[14]:
In [15]:
wikipg = list(rd.get_wiki_pages())[4]
In [16]:
from string import maketrans # Required to call maketrans function.
intab = "aeiou"
outtab = "12345"
trantab = maketrans(intab, outtab)
str = "this is string example....wow!!!";
print str.translate(trantab);
In [17]:
wikipg.has_fetched
Out[17]:
In [18]:
wikipg.revision_by
Out[18]:
In [19]:
#wikipg.content_html
In [20]:
savmd = open('wiki.md', 'w')
In [21]:
wikip = wikipg.content_md
In [22]:
savmd.write(wikip)
In [23]:
savmd.close()
In [24]:
allmods = list(rd.get_moderators())
In [25]:
allmods.sort()
In [26]:
modzro = allmods[3]
In [27]:
modcom = modzro.get_comments()
In [28]:
banlolz = []
In [29]:
for infz in modcom:
print infz
banlolz.append(infz)
In [30]:
len(banlolz)
banlizt = []
In [31]:
for banz in banlolz:
print banz
banlizt.append((banz.body))
In [32]:
blsz = []
In [33]:
banlizt
for bez in banlizt:
print bez
#if 'remove' or 'banned' in bez:
# blsz.append(bez)
In [34]:
blsz
Out[34]:
In [1493]:
izone = banlizt[0]
In [35]:
szone = str(izone())
In [1492]:
str = banlizt;
print str.translate(trantab);
In [1074]:
modzro.fullname
Out[1074]:
In [1075]:
print infz.subreddit
In [1076]:
print infz.body
In [1077]:
rd.get_rising
Out[1077]:
In [1078]:
rd.get_top_from_year
Out[1078]:
In [1079]:
rd.get_stylesheet()
Out[1079]:
In [1080]:
seclis = list(rd.get_comments())
In [1081]:
newcoms = []
In [1082]:
for comes in seclis:
print (comes)
newcoms.append(comes)
In [1083]:
senrgd = []
In [1084]:
for comz in newcoms:
print comz
senrgd.append(comz.submission.url)
In [1085]:
import pyimgur
In [1086]:
pyimgur.Imgur.upload_image
Out[1086]:
In [1087]:
comz.submission.url
Out[1087]:
In [1088]:
allcom = r.get_subreddit('redditgetsdrawn')
In [1367]:
lisbox = senrgd[1]
In [1368]:
import bs4
In [1369]:
soup = bs4.BeautifulSoup(lisbox)
In [1091]:
soup.contents
Out[1091]:
In [1092]:
soup.index
Out[1092]:
In [1093]:
print soup.name
print soup.contents
In [1379]:
myString = str(soup.string)
rdgimg = re.search("(?P<url>https?://[^\s]+)", myString).group("url")
In [1095]:
from IPython.display import Image
In [1112]:
print rdgimg
In [1101]:
os.chdir('/home/wcmckee/rgd')
In [1102]:
import requests
In [1103]:
reqrgd = requests.get(rdgimg)
In [1104]:
#reqrgd.text
In [1105]:
finz = (comus + '.jpg')
In [1106]:
savrgd = open(finz, 'wb')
In [1107]:
savrgd.write(reqrgd.url)
savrgd.close()
In [1110]:
finz
Out[1110]:
In [1108]:
import urllib
resource = urllib.urlopen(rdgimg)
output = open(finz,"wb")
output.write(resource.read())
output.close()
In [1109]:
ls
In [849]:
dizusr = Image(filename=finz)
In [ ]:
In [850]:
dizusr
Out[850]:
In [1415]:
#r.login('snatchrgd', 'camp123')
r.login('artcontrol', 'test123')
In [1416]:
r.client_id
In [1417]:
redfront = r.get_front_page()
In [1418]:
for red in redfront:
print red
In [1419]:
red
Out[1419]:
In [1420]:
red.comments
Out[1420]:
In [1421]:
red.downs
Out[1421]:
In [1422]:
red.title
Out[1422]:
In [1423]:
mymod = r.get_my_moderation()
In [1424]:
for mo in mymod:
print mo
In [1513]:
rdrawn = r.get_subreddit('redditgetsdrawn')
In [1514]:
rdrawn.subscribe()
In [1515]:
rdnew = rdrawn.get_new
In [1516]:
rdrawn.submit('test', rdgimg)
In [1430]:
redls = []
In [1431]:
for rd in rdnew():
print rd
redls.append(rd)
In [1432]:
rd.selftext
In [1433]:
rdurlz = []
rdusers = []
In [1434]:
for itez in redls:
print itez.url
rdurlz.append(itez.url)
rdusers.append(itez.author)
In [1435]:
uzrlaz = []
In [1436]:
rgdict = {'user': 'wcmckee', 'img': 'test'}
linkdict = {'links': 'artcontrol', 'user': 'url'}
In [1437]:
for rduzr in rdusers, :
print rduzr
uzrlaz.append(str(rduzr))
rgdict.update({str(rduzr): 'url'})
In [1438]:
for itez in redls:
print itez.url
linkdict.update({str(itez.author):itez.url})
In [1439]:
linkdict
Out[1439]:
In [1440]:
rgdict
Out[1440]:
In [1441]:
for rez in uzrlaz:
rgdict.update({'user': rez})
In [1442]:
rgdict
Out[1442]:
In [1443]:
rgdict.update({'id': rez})
In [1444]:
rgdict
Out[1444]:
In [1445]:
uzrlaz
Out[1445]:
In [1446]:
rd.downs
rd.ups
In [1536]:
nezlis = []
In [1537]:
#rdurlz
for jpgz in rdurlz:
if '.jpg' in jpgz:
nezlis.append(jpgz)
#else print 'didnt append'
#if '*.jpg' in rdurlz:
# print '*.jpg'
In [1538]:
nezlis
Out[1538]:
In [1530]:
import random
In [1531]:
lrdz = len(rdurlz)
In [1532]:
recrand = random.randint(0, lrdz)
In [1533]:
recrand
Out[1533]:
In [1534]:
freimg = nezlis[recrand]
In [1535]:
strfre = str(freimg)
In [1535]:
In [1529]:
Image(strfre)
Out[1529]:
In [1188]:
resource = urllib.urlopen(rdgimg)
output = open(fulzname,"w")
output.write(rdgimg)
output.close()
In [ ]:
import o
In [1215]:
fulzname
Out[1215]:
In [1216]:
rdurlz
Out[1216]:
In [1217]:
savreq = requests.get(rdurlz[7])
In [1218]:
rezlz = redls[0]
In [1219]:
reuzrz = rezlz.author
In [1220]:
usrzname = str(reuzrz.name)
In [1221]:
fulzname = (usrzname + '.jpg')
In [1222]:
resource = urllib.urlopen(rdgimg)
output = open(fulzname,"w")
output.write(rdgimg)
output.close()
In [1223]:
fulzname
Out[1223]:
In [1224]:
Image(fulzname)
Out[1224]:
In [1225]:
ls
In [1199]:
rgdtit = rd.title
In [1226]:
rdurlz = str(rd.url)
In [1227]:
rdauth =rd.author
In [1228]:
rdusern = str(rdauth.name)
In [1229]:
rdauth.is_gold
Out[1229]:
In [1230]:
rdauth.json_dict
In [1231]:
rdauth.id
Out[1231]:
In [1232]:
rdsub = rdauth.get_submitted
In [1233]:
for rsu in rdsub():
print rsu
In [1234]:
rsu.selftext
Out[1234]:
In [1235]:
othasub = rsu.subreddit
In [1236]:
print othasub
In [1362]:
artget = r.get_subreddit('artcontroldrawsyou')
In [1363]:
artget.submit(rdusern, rdurlz )
In [1239]:
artctrl = r.get_redditor('artcontrol')
In [1240]:
arlik = artctrl.get_liked
In [1241]:
arlik
Out[1241]:
In [1242]:
print arlik
In [1243]:
print arlik()
In [1413]:
ls
In [1409]:
drzu = r.get_subreddit('artcontroldrawsyou')
In [1410]:
drzu
Out[1410]:
In [1414]:
drzu.upload_image()
In [ ]: