|
|
|
@ -8,7 +8,6 @@ headers = {}
|
|
|
|
|
headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36' |
|
|
|
|
|
|
|
|
|
def reddit_parse_hot(reddit, sub , many): |
|
|
|
|
loop = 0 |
|
|
|
|
what_to_parse = reddit.subreddit(sub) |
|
|
|
|
hot_posts = what_to_parse.hot(limit = many) |
|
|
|
|
for post in hot_posts: |
|
|
|
@ -17,11 +16,9 @@ def reddit_parse_hot(reddit, sub , many):
|
|
|
|
|
req = request.Request(post_url, headers = headers) |
|
|
|
|
url_opn = request.urlopen(req) |
|
|
|
|
url_opn_list.append(post_url) |
|
|
|
|
loop += 1 |
|
|
|
|
return url_opn_list |
|
|
|
|
|
|
|
|
|
def reddit_parse_time(reddit, sub, many): |
|
|
|
|
loop = 0 |
|
|
|
|
what_to_parse = reddit.subreddit(sub) |
|
|
|
|
time_posts = what_to_parse.new(limit = many) |
|
|
|
|
for post in time_posts: |
|
|
|
@ -30,12 +27,10 @@ def reddit_parse_time(reddit, sub, many):
|
|
|
|
|
req = request.Request(post_url, headers = headers) |
|
|
|
|
url_opn = request.urlopen(req) |
|
|
|
|
url_opn_list.append(post_url) |
|
|
|
|
loop += 1 |
|
|
|
|
return url_opn_list |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def random_subreddit(reddit,many): |
|
|
|
|
loop = 0 |
|
|
|
|
what_to_parse = reddit.subreddit('random') |
|
|
|
|
hot_posts = what_to_parse.hot(limit = many) |
|
|
|
|
for post in hot_posts: |
|
|
|
@ -44,5 +39,4 @@ def random_subreddit(reddit,many):
|
|
|
|
|
req = request.Request(post_url, headers = headers) |
|
|
|
|
url_opn = request.urlopen(req) |
|
|
|
|
url_opn_list.append(post_url) |
|
|
|
|
loop += 1 |
|
|
|
|
return url_opn_list, what_to_parse |
|
|
|
|