所以我使用 selenium 抓取链接。我可以用我的循环打印我的链接,但我无法导航到它们,因为我收到以下错误:
selenium.common.exceptions.StaleElementReferenceException:消息:元素引用已过时;要么元素不再附加到 DOM,它不在当前框架上下文中,要么文档已被刷新
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.famousgraphicdesigners.org/")
links = driver.find_elements_by_xpath('//*[@id="pages-2"]/div/ul/li/a')
links_total = len(links)
print("Found", links_total, "total links.\n")
for i in links:
# print(i.get_attribute('href')) # This works
driver.get(i.get_attribute('href')) # This doesnt work
driver.quit()