Я пытаюсь очистить ЭТОТ WALMART URL , используя Python Селен и Фантом JS. Этот сайт имеет конечную прокрутку, но я не могу получить URL всех продуктов. Похоже, этот сайт мешает моему коду загружать другие продукты
def check_exists_by_xpath(xpath):
try:
browser.find_element_by_xpath(xpath)
except NoSuchElementException:
return False
return True
SCROLL_PAUSE_TIME = 0.5
browser.execute_script("scrollToTopComponent.scrollTop = scrollToTopComponent.scrollHeight-(scrollToTopComponent.scrollHeight/2);")
while not check_exists_by_xpath('//*[@id="scrollToTopComponent"]/section/div[1]/div[3]/div[2]/div/div/div[80]/h2'):
# browser.save_screenshot(str(i)+".png")
browser.execute_script(
"scrollToTopComponent.scrollTop = scrollToTopComponent.scrollHeight;")
if check_exists_by_xpath('//*[@id="root"]/div/div[2]/div/div/div/button[2]'):
browser.find_element_by_xpath('//*[@id="root"]/div/div[2]/div/div/div/button[2]').click()
time.sleep(SCROLL_PAUSE_TIME)
new_height = browser.execute_script("return scrollToTopComponent.scrollHeight;")
i = i + 1
# browser.save_screenshot(str(i) + ".png")
print(new_height)
print("broke")