You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
892B

  1. import requests
  2. import random
  3. from libs.scrapper.scrappersites import imgur, reddit, gfy, tumblr
  4. class scrapper():
  5. def __init__(self):
  6. pass
  7. def linkget(self, subreddit, israndom):
  8. if israndom:
  9. options = [".json?count=100", "/top/.json?sort=top&t=all&count=100"]
  10. choice = random.choice(options)
  11. subreddit += choice
  12. html = requests.get("https://reddit.com/r/"+subreddit, headers = {'User-agent': 'RoxBot Discord Bot'})
  13. reddit = html.json()["data"]["children"]
  14. return reddit
  15. def retriveurl(self, url):
  16. url2 = ""
  17. if "imgur" in url:
  18. url2 = imgur.imgur().get(url)
  19. elif "gfycat" in url:
  20. url2 = gfy.gfycat().get(url)
  21. elif "eroshare" in url:
  22. #eroshare.eroshare().get(url)
  23. pass
  24. elif "redd.it" in url or "i.reddituploads" in url:
  25. url2 = reddit.reddit().get(url)
  26. elif "media.tumblr" in url:
  27. url2 = tumblr.tumblr().get(url)
  28. print(url)
  29. return url2