🐛 Fixed image bug
Changed what the code looks for on the bing page
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user