Quellcode durchsuchen

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

tags/v0.4.0
roxie vor 6 Jahren
Ursprung
Commit
fe6623a932
3 geänderte Dateien mit 9 neuen und 3 gelöschten Zeilen
  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 Datei anzeigen

import random import random
import discord
from pprint import pprint
from libs.scrapper.scrapper import scrapper from libs.scrapper.scrapper import scrapper
from discord.ext.commands import bot from discord.ext.commands import bot



+ 4
- 1
libs/scrapper/scrapper.py Datei anzeigen

choice = random.choice(options) choice = random.choice(options)
subreddit += choice subreddit += choice
html = requests.get("https://reddit.com/r/"+subreddit, headers = {'User-agent': 'RoxBot Discord Bot'}) 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 return reddit


def retriveurl(self, url): def retriveurl(self, url):

+ 5
- 0
libs/scrapper/scrappersites/imgur.py Datei anzeigen

if "imgur" in img["src"]: if "imgur" in img["src"]:
if not img["src"] in links: if not img["src"] in links:
links.append(img["src"]) 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: if len(links) > 1:
return url return url
else: else:

Laden…
Abbrechen
Speichern