python - 程序在工作过程中出错
问题描述
抓取网站时,一切顺利,直到程序在向下滚动几次后出现此错误
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=91.0.4472.77)
def gsrc(A):
[list_src.add(src.get_attribute("src")) for src in A]
for i in range(100):
b.execute_script("window.scrollTo(0,document.body.scrollHeight);")
A=b.find_elements_by_css_selector('.KL4Bh img')
gsrc(A)
time.sleep(5)
是什么原因?
解决方案
推荐阅读
- charts - 为 Apexcharts 柱形图设置最小高度或宽度
- java - Intellij Idea: sbt refresh FetchError$DownloadingArtifacts npm-4.2.0-sources.jar: not found
- python - 如果与多个实现链接,numpy 使用哪个 blas 实现
- javascript - Puppeteer 中无头与非无头配置的不同屏幕截图
- html - 能
和 - .net - Azure App 洞察响应时间 HTTP 和 appservice 中记录的第一个依赖项之间的差异
- regex - 使用正则表达式的最近匹配
- java - 删除java中2个字符之间的空格
- typescript - TypeScript: ReturnType -> 如何设置函数返回的函数的返回类型
- android - 用于 EddyStone 信标的 Android 信标库