元素在检查模式下具有 ID,但在原始 HTML 中没有 [英] Element has ID in inspection mode, but not in raw HTML

查看:15
本文介绍了元素在检查模式下具有 ID,但在原始 HTML 中没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 Python 和 Selenium 开发一个小型网页抓取脚本.

I am currently working on a small web scraping script with Python and Selenium.

我试图从一个表中获取一些信息,该表在检查模式下具有某个 ID.但是,当我以原始 HTML 格式打开页面时(我在无法使用 xpath 或 css_selector 找到该表之后才这样做),该表没有提到的 ID.

I am trying to get some information from a table, which has in inspection mode a certain ID. However, when I open the page as raw HTML (which I did after not being able to locate that table using neither xpath or css_selector), the table does not have the mentioned ID.

这怎么可能?

为了更好的解释:

这就是我的浏览器在检查模式下的样子

This is what it looks like in inspection mode in my browser

<table id='ext-gen1076' class='bats-table bats-table--center'>
[...]
</table>

这就是当我将页面作为原始 HTML 文件打开时的样子

And this is what it looks like when I open the page as raw HTML file

<table class='bats-table bats-table--center'>
[...]
</table>

ID 怎么可能会消失?(JFI,这是我的第一个问题,对于格式错误,我深表歉意!).

How is it possible, that the ID is simply disappearing? (JFI, this is my first question so apologies for the bad formatting!).

提前致谢!

推荐答案

原因是ID是在运行时添加的.

The reason is, the ID was added during the runtime.

这篇关于元素在检查模式下具有 ID,但在原始 HTML 中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆