From a376c28207c2c6c8e7bb93c57f18682ab465113b Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 23 Oct 2020 10:06:43 -0400 Subject: [PATCH] Fix other index error --- src/cogs/weeb.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cogs/weeb.py b/src/cogs/weeb.py index 87e1ee6..678404a 100644 --- a/src/cogs/weeb.py +++ b/src/cogs/weeb.py @@ -48,8 +48,14 @@ class Weeb(cmds.Cog): url = 'https://www.deskhero.ca/products/gmk-metaverse-2' browser.get(url) - royal_soldout = browser.find_elements_by_css_selector('#data-product-option-1-1')[0].get_attribute('data-soldout') - novelties_soldout = browser.find_elements_by_css_selector('#data-product-option-1-3')[0].get_attribute('data-soldout') + try: + royal_soldout = browser.find_elements_by_css_selector('#data-product-option-1-1')[0].get_attribute('data-soldout') + except IndexError: + royal_soldout = 'true' + try: + novelties_soldout = browser.find_elements_by_css_selector('#data-product-option-1-3')[0].get_attribute('data-soldout') + except IndexError: + novelties_soldout = 'true' if royal_soldout != 'true': message += f'Royal is in stock at Deskhero!\n<{url}>\n'