使用 Selenium RC 从 id 获取 img 文件名

发布于 2024-09-27 03:44:15 字数 155 浏览 0 评论 0原文

我正在尝试获取图像文件名 - 我的网页基于输入,正在加载多个图像,我想获取图像的文件名。如果我知道 ID 或替代文本,我可以获取图像文件名吗?现在,我正在使用“get_html_source”(python,顺便说一句)并从那里解析它。有没有其他选择,或者 selenium 并不是为此而构建的?

I'm trying to grab the image filename - my webpage, based on inputs, is loading on of several images and I want to grab the filename of the image. If I know the id or the alt-text, can I grab the image filename? Right now, I'm using "get_html_source" (python, btw) and parsing it from there. Is there an alternative, or is selenium not really built for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慕烟庭风 2024-10-04 03:44:15

使用get_attribute

sel.get_attribute('//path/to/my/img@src')

Use get_attribute:

sel.get_attribute('//path/to/my/img@src')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文