From 566c7b6794ffc7f8432309ff8e4eb6d1e615298b Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Tue, 6 Apr 2021 16:15:56 +0200 Subject: [PATCH] :bug: Fixed image bug Changed what the code looks for on the bing page --- funcs/other/other.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/funcs/other/other.py b/funcs/other/other.py index c4a6290..e63fbb9 100644 --- a/funcs/other/other.py +++ b/funcs/other/other.py @@ -6,6 +6,7 @@ import urllib # Used in imageFunc import lxml # Used in imageFunc import wikia # Used in findWikiPage import d20 # Used in rollDice +import ast from .bedreNetflix import BedreNetflix from .nerdShit import NerdShit from .generators import Generators @@ -115,21 +116,22 @@ class Other(): page = urllib.request.urlopen("https://www.bing.com/images/search?q="+search+"&safesearch=off") read = page.read() tree = lxml.etree.HTML(read) - images = tree.xpath('//a[@class = "thumb"]/@href') + images = tree.xpath('//a[@class = "iusc"]/@m') if len(images) == 0: await ctx.send("Found no images") else: # Picks an image number = random.randint(1,len(images))-1 - image = images[number] + image = ast.literal_eval(str(images[number])) + imageUrl = image["murl"] self.bot.log("Picked image number "+str(number)) # Returns the image self.bot.log("Successfully returned an image") - await ctx.send(image) + await ctx.send(imageUrl) # Finds a page from the Senkulpa Wikia async def findWikiPage(self, ctx, search : str):