无法访问模态元素以使用硒下载PDF
我正在网上抓取一个网站,该网站打开了要在模态视图中访问的PDF。我想下载/访问此PDF。
它可以在模式下以PDF查看器的形式打开,我无法通过XPath访问下载按钮或任何其他元素。 通过XPATH访问任何元素时,它将返回一个空列表。
I am web scraping a website that opens up the pdf I want to access in a modal view. I want to download/access this pdf.
It opens up as a pdf viewer in a modal and I can't access the download button or any other element through the Xpath.
On accessing any element through Xpath, it returns an empty list .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我注意到您关于模态视图的检查部分的屏幕截图。
该元素具有属性
Original_url
是PDF文件的原始URL。并引用这个答案,您可以尝试通过配置
webdrover.chromeoptions.chromeoptions() /代码>。
因此,在您的情况下,可能是这样:
I noticed that your screenshot about The inspect section of the modal view .
The element has an attribute
original_url
which is the original url of the pdf file.And reference to this answer, you can try to directly download the pdf file by configurating
webdriver.ChromeOptions()
.So in your case it can be like this: