Fixed exception handling
This commit is contained in:
@@ -45,15 +45,15 @@ def get_image(soup, etree_soup):
|
||||
image = dom.xpath('//*[@id="main-image-container"]/ul/li[4]/span/span/div/img')
|
||||
image = image[0].get('src')
|
||||
except IndexError:
|
||||
logging.info("Couldn't retrieve image, trying with xpath method")
|
||||
try:
|
||||
logging.info("Couldn't retrieve image, trying with xpath method 2")
|
||||
dom = etree.HTML(str(etree_soup))
|
||||
image = dom.xpath('//*[@id="main-image-container"]/ul/li[5]/span/span/div/img')
|
||||
image = image[0].get('src')
|
||||
except AttributeError:
|
||||
logging.info("Couldn't retrieve image with xpath method, falling back to placeholder")
|
||||
image = "N/A"
|
||||
except Exception as e:
|
||||
logging.info("Couldn't retrieve image with xpath method, falling back to placeholder")
|
||||
logging.info(f"Error retrieving image: {e}")
|
||||
image = "N/A"
|
||||
except Exception as e:
|
||||
logging.info(f"Error retrieving image: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user