Fixing price lookups for ships with a try except
This commit is contained in:
parent
d62e674106
commit
df44f23273
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user