Syncing old changes...

This commit is contained in:
Joan
2023-08-28 20:51:29 +02:00
parent d99399f6ac
commit e124ca4f2f
2 changed files with 15 additions and 4 deletions

View File

@@ -40,8 +40,17 @@ def get_image(soup, etree_soup):
dom = etree.HTML(str(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")
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"
image = "N/A"
except Exception as e:
logging.info(f"Error retrieving image: {e}")
except Exception as e:
logging.info(f"Error retrieving image: {e}")
return image