On corrige de petites erreurs dasn la gestion des cookies fb

This commit is contained in:
Jean-Marie Favreau 2025-02-21 16:14:23 +01:00
parent 9475c99e0f
commit d3cd57edaf
2 changed files with 14 additions and 5 deletions

View File

@ -244,10 +244,19 @@ class FacebookEventExtractor(Extractor):
from selenium.webdriver.support import expected_conditions as EC
path = './/div[not(@aria-hidden)]/div[@aria-label="Allow all cookies"]'
element = WebDriverWait(downloader.driver, 10).until(EC.visibility_of_element_located((By.XPATH, path)))
try:
element = WebDriverWait(downloader.driver, 15).until(EC.visibility_of_element_located((By.XPATH, path)))
except Exception as e:
raise Exception(_("Error while waiting for the cookie button to be visible: " + e.__class__.__name__ + ' ' + str(e)))
try:
button = downloader.driver.find_element(By.XPATH, path)
except Exception as e:
raise Exception(_("Error while getting the cookie button to be visible: " + e.__class__.__name__ + ' ' + str(e)))
try:
button.click()
t.sleep(3)
except Exception as e:
raise Exception(_("Error while clicking on the cookie button to be visible: " + e.__class__.__name__ + ' ' + str(e)))
t.sleep(5)
def prepare_2nd_extract(self):
FacebookEventExtractor.prepare_2nd_extract_dler(self.downloader)

View File

@ -262,7 +262,7 @@ class TwoStepsExtractor(Extractor):
)
except Exception as e:
# some website (FB) sometime need a second step
if first and len(self.events) == 0 and self.has_2nd_method_in_list and self.downloader.support_2nd_extract:
if first and self.has_2nd_method_in_list and self.downloader.support_2nd_extract:
logger.info('Using cookie trick on a facebook event')
first = False
self.prepare_2nd_extract_in_list()