@@ -1,6 +1,4 @@ | |||
import random | |||
import discord | |||
from pprint import pprint | |||
from libs.scrapper.scrapper import scrapper | |||
from discord.ext.commands import bot | |||
@@ -12,7 +12,10 @@ class scrapper(): | |||
choice = random.choice(options) | |||
subreddit += choice | |||
html = requests.get("https://reddit.com/r/"+subreddit, headers = {'User-agent': 'RoxBot Discord Bot'}) | |||
reddit = html.json()["data"]["children"] | |||
try: | |||
reddit = html.json()["data"]["children"] | |||
except KeyError: | |||
return False | |||
return reddit | |||
def retriveurl(self, url): |
@@ -32,6 +32,11 @@ class imgur(): | |||
if "imgur" in img["src"]: | |||
if not img["src"] in links: | |||
links.append(img["src"]) | |||
for video in soup.find_all("source"): | |||
if "imgur" in video["src"]: | |||
if not video["src"] in links: | |||
links.append(video["src"]) | |||
if len(links) > 1: | |||
return url | |||
else: |