Message: The element reference of <...> is stale; either the element is no longer attached to the DOM

При работе парсера парсинг 5 страницы прерывается выбивая ошибку

Message: The element reference of <div class="product-item products-list__item js-item _with-bonus _blocks-replaced"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed

В чем может быть проблема?

Отладчик указывает на эту часть кода:

 while True:
                try:
                    # Добавляем в селекторе ограничение на data-product-url, чтобы не зацепить пустой элемент
                    items_el = wait.until(
                        EC.visibility_of_any_elements_located(
                            (By.CSS_SELECTOR, ".product-item[data-product-url]")
                        )
                    )
                    break
                except TimeoutException:
                    pass
                try:
                    items_el = wait.until(EC.visibility_of_any_elements_located(
                        By.CLASS_NAME, "product-item products-list__item js-item _with-bonus _blocks-replaced"
                                                                                
                                             )
                                          )
                    break
                except TimeoutException:
                    pass
      

Ссылка на весь код: https://replit.com/@Konstantin-Niko/Parcer#ParcerComfy.py


Ответы (0 шт):