Browse Source

fun cog finished for this update. Aww and reddit both added.

tags/v0.4.0
roxie 6 years ago
parent
commit
fe6623a932
3 changed files with 9 additions and 3 deletions
  1. +0
    -2
      cogs/Fun.py
  2. +4
    -1
      libs/scrapper/scrapper.py
  3. +5
    -0
      libs/scrapper/scrappersites/imgur.py

+ 0
- 2
cogs/Fun.py View File

@@ -1,6 +1,4 @@
import random
import discord
from pprint import pprint
from libs.scrapper.scrapper import scrapper
from discord.ext.commands import bot


+ 4
- 1
libs/scrapper/scrapper.py View File

@@ -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):

+ 5
- 0
libs/scrapper/scrappersites/imgur.py View File

@@ -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:

Loading…
Cancel
Save