- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个脚本(在 <script></script>
标签内),每次加载页面时都会执行该脚本。是否可以在 WebDriver 中加载页面之前删除 WebElement 以防止该脚本执行?
我在想一些事情:
以某种方式获取原始 HTML 代码(可能获取源代码或其他东西),删除部分(使用 selenium 或解析器),将编辑后的代码“注入(inject)”回 Selenium(Firefox WebDriver 或可能是 PhantomJS)最后对该网站上的所有页面执行它。
是否可以这样做,或者这在设计上是不可能的?
最佳答案
如果安装 selenium-requests ,您可以对页面发出 GET 请求,处理加载的 html/etc,然后然后放置在选项卡中。
插入处理后的结果可能会很棘手,因为您可能还需要设置当前浏览器 URL 以匹配(简单地插入它会导致脚本跨域加载、相对路径等问题)——也许有一种覆盖(或允许覆盖)selenium 使用预处理信息接收的“获取”响应的方法
Selenium-Requests makes a request using the requests library that uses the running webdriver's cookies for that domain and emulates the default HTTP headers sent by that webdriver. The result is a low-level HTTP request and response created with the webdriver's state. This is needed because the Selenium interface is very high-level, and doing much more than opening pages and exploring the DOM is not really natively possible in Python.
关于python - 在 WebDriver 中加载页面之前删除部分 HTML - Selenium & Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39672696/
我正在开发一个需要能够平均三个数字的 Facebook 应用程序。但是,它总是返回 0 作为答案。这是我的代码: $y = 100; $n = 250; $m = 300; $number = ($y
我只是无法弄清楚这一点,也找不到任何对我来说有意义的类似问题。我的问题:我从数据库中提取记录,并在我的网页上以每个面板 12 条的倍数显示它们。因此,我需要知道有多少个面板可以使用 JavaScrip
我是一名优秀的程序员,十分优秀!