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 6425bf5ea0
commit edfcd35989

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
manufacturer = (
soup.find("div", {"class": "infobox__subtitle infobox__data"})
.findNext("a")
.text
)
try:
manufacturer = (
soup.find("div", {"class": "infobox__subtitle infobox__data"})
.findNext("a")
.text
)
except:
manufacturer = ""
embed.set_thumbnail(
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),
)
ship_role = (
soup.find("div", {"class": "infobox__label"}, string="Role")
.findNext("div")
.text
)
try:
ship_role = (
soup.find("div", {"class": "infobox__label"}, string="Role")
.findNext("div")
.text
)
except:
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)" % (
ingame_price,
wiki_url,
wiki_ship_name,
)
price = "[%s](%s%s#Universe_availability)" % (
ingame_price,
wiki_url,
wiki_ship_name,
)
if "Not available" in ingame_price:
if "Not available" in ingame_price:
price = "N/A"
except:
price = "N/A"
embed.add_field(