WIP fix to aiohttp payload error

pull/129/head
bobloy 5 years ago
parent a4a787830a
commit 9ef5836fa8

@ -22,18 +22,19 @@ class LoveCalculator(Cog):
x = lover.display_name x = lover.display_name
y = loved.display_name y = loved.display_name
url = "https://www.lovecalculator.com/love.php?name1={}&name2={}".format( url = f"https://www.lovecalculator.com/love.php?name1={x}&name2={y}"
x.replace(" ", "+"), y.replace(" ", "+")
)
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get(url) as response: async with session.get(url) as response:
soup_object = BeautifulSoup(await response.text(), "html.parser") resp = await response.text()
soup_object = BeautifulSoup(resp, "html.parser")
try: try:
description = ( description = soup_object.find("div", attrs={"class": "result__score"}).get_text().strip()
soup_object.find("div", attrs={"class": "result__score"}).get_text().strip() img = soup_object.find("img", attrs={"class": "result__image"})['src']
)
except: except:
description = "Dr. Love is busy right now" description = "Dr. Love is busy right now"
img = None
try: try:
z = description[:2] z = description[:2]
@ -48,5 +49,5 @@ class LoveCalculator(Cog):
title = "Dr. Love has left a note for you." title = "Dr. Love has left a note for you."
description = emoji + " " + description + " " + emoji description = emoji + " " + description + " " + emoji
em = discord.Embed(title=title, description=description, color=discord.Color.red()) em = discord.Embed(title=title, description=description, color=discord.Color.red(), url=img)
await ctx.send(embed=em) await ctx.send(embed=em)

Loading…
Cancel
Save