Fixing price lookups for ships with a try except

This commit is contained in:
Luke Robles 2023-06-01 17:54:19 -07:00
parent 183d9aa8e8
commit 610237daef

View File

@ -29,12 +29,14 @@ async def get_ship(ship_name):
) )
ship_name_on_page = soup.find("span", {"class": "mw-page-title-main"}).text ship_name_on_page = soup.find("span", {"class": "mw-page-title-main"}).text
try:
manufacturer = ( manufacturer = (
soup.find("div", {"class": "infobox__subtitle infobox__data"}) soup.find("div", {"class": "infobox__subtitle infobox__data"})
.findNext("a") .findNext("a")
.text .text
) )
except:
manufacturer = ""
embed.set_thumbnail( embed.set_thumbnail(
url="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png" url="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png"
@ -45,23 +47,29 @@ async def get_ship(ship_name):
url="%s%s" % (wiki_url, wiki_ship_name), url="%s%s" % (wiki_url, wiki_ship_name),
) )
ship_role = ( try:
soup.find("div", {"class": "infobox__label"}, string="Role") ship_role = (
.findNext("div") soup.find("div", {"class": "infobox__label"}, string="Role")
.text .findNext("div")
) .text
)
except:
ship_role = ""
embed.add_field(name="**Role**", value=ship_role) embed.add_field(name="**Role**", value=ship_role)
ingame_price = soup.find("td", {"class": "Price smwtype_qty"}).text try:
ingame_price = soup.find("td", {"class": "Price smwtype_qty"}).text
price = "[%s](%s%s#Universe_availability)" % ( price = "[%s](%s%s#Universe_availability)" % (
ingame_price, ingame_price,
wiki_url, wiki_url,
wiki_ship_name, wiki_ship_name,
) )
if "Not available" in ingame_price: if "Not available" in ingame_price:
price = "N/A"
except:
price = "N/A" price = "N/A"
embed.add_field( embed.add_field(