updated after a while because local stuff

This commit is contained in:
2017-11-10 22:58:01 +01:00
parent 4e44b73542
commit 21df9b0df5
95 changed files with 27441 additions and 25 deletions
+58
View File
@@ -0,0 +1,58 @@
import os
import json
import argparse
import praw
from time import sleep
from urllib.request import (Request, urlopen, urlretrieve)
def main():
r = praw.Reddit(
user_agent='StroopwafelBot',
client_secret='Z4K17T8TC26cNAgDSRxCkE9jYR4',
client_id='aWeyKpzdHMtmJQ'
)
r.read_only = True
sub = r.subreddit('NekoIRL')
print(sub.random().url)
if __name__ == "__main__":
main()
#def main():
#
# parser = argparse.ArgumentParser()
# parser.add_argument('--sub', '-s')
# args = parser.parse_args()
# sub = args.sub
# imgs_folder = 'imgs_' + sub
# imgs_url = 'https://www.reddit.com/r/' + sub + '/top.json'
# #imgs_url = 'https://www.reddit.com/r/' + sub + '/about/stylesheet.json'
# req = Request(imgs_url)
# req.add_header('User-agent', 'Stylesheet images downloader Py3 v1')
# imgs_json = json.loads(urlopen(req).read())
# imgs = [i for i in imgs_json['data']['children']]
#
# def fetch_images(total, count):
# if not os.path.exists(imgs_folder):
# os.makedirs(imgs_folder)
# os.chdir(imgs_folder)
#
# for i in imgs:
# url = i['url']
# ext = '.' + url.split('.')[-1]
# name = i['name'] + ext
# urlretrieve(url, name)
# print('Downloading ' + str(count) + ' of ' + str(total) + ' - ' + name)
# count += 1
# sleep(1)
#
# if imgs:
# total = len(imgs)
# fetch_images(total, count=1)
# else:
# print("No images found")
#
#if __name__ == "__main__":
# main()
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB