diff --git a/app/star_citizen.py b/app/star_citizen.py index 88d0cd08..f4eb3178 100644 --- a/app/star_citizen.py +++ b/app/star_citizen.py @@ -11,6 +11,7 @@ async def get_ship(ship_name): wiki_ship_name = "_".join(elem.capitalize() for elem in ship_name.split()) # print(wiki_ship_name) + # print("%s%s" % (wiki_url, wiki_ship_name)) headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0" @@ -80,30 +81,39 @@ async def get_ship(ship_name): .find("div", {"class": "infobox-data__value"}) .text ) - - expedited_claim_time = ( - soup.find("div", {"class": "data-expeditetime infobox-data infobox-col4"}) - .find("div", {"class": "infobox-data__value"}) - .text - ) - expedited_fee = ( - soup.find("div", {"class": "data-expeditecost infobox-data infobox-col2"}) - .find("div", {"class": "infobox-data__value"}) - .text - ) - embed.add_field(name="**Insurance claim time**", value=claim_time, inline=True) - embed.add_field( - name="**Expedite claim time**", value=expedited_claim_time, inline=True - ) - embed.add_field(name="**Expedite Fee**", value=expedited_fee, inline=True) + try: + expedited_claim_time = ( + soup.find( + "div", {"class": "data-expeditetime infobox-data infobox-col4"} + ) + .find("div", {"class": "infobox-data__value"}) + .text + ) + embed.add_field( + name="**Expedite claim time**", value=expedited_claim_time, inline=True + ) + except Exception: + pass + + try: + expedited_fee = ( + soup.find( + "div", {"class": "data-expeditecost infobox-data infobox-col2"} + ) + .find("div", {"class": "infobox-data__value"}) + .text + ) + embed.add_field(name="**Expedite Fee**", value=expedited_fee, inline=True) + except Exception: + pass embed.add_field( name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False ) - except Exception: + except Exception as e: embed = discord.Embed(description="❌", color=discord.Color.red(), type="rich") embed.add_field( name="**Could not find that ship**",