<bdo id='N4ahR'></bdo><ul id='N4ahR'></ul>
      1. <tfoot id='N4ahR'></tfoot>
      2. <small id='N4ahR'></small><noframes id='N4ahR'>

        <legend id='N4ahR'><style id='N4ahR'><dir id='N4ahR'><q id='N4ahR'></q></dir></style></legend>

        <i id='N4ahR'><tr id='N4ahR'><dt id='N4ahR'><q id='N4ahR'><span id='N4ahR'><b id='N4ahR'><form id='N4ahR'><ins id='N4ahR'></ins><ul id='N4ahR'></ul><sub id='N4ahR'></sub></form><legend id='N4ahR'></legend><bdo id='N4ahR'><pre id='N4ahR'><center id='N4ahR'></center></pre></bdo></b><th id='N4ahR'></th></span></q></dt></tr></i><div id='N4ahR'><tfoot id='N4ahR'></tfoot><dl id='N4ahR'><fieldset id='N4ahR'></fieldset></dl></div>

        不要等待在 Python 中使用 Selenium 加载页面

        时间:2023-07-04
            <tbody id='FDTQH'></tbody>
          <i id='FDTQH'><tr id='FDTQH'><dt id='FDTQH'><q id='FDTQH'><span id='FDTQH'><b id='FDTQH'><form id='FDTQH'><ins id='FDTQH'></ins><ul id='FDTQH'></ul><sub id='FDTQH'></sub></form><legend id='FDTQH'></legend><bdo id='FDTQH'><pre id='FDTQH'><center id='FDTQH'></center></pre></bdo></b><th id='FDTQH'></th></span></q></dt></tr></i><div id='FDTQH'><tfoot id='FDTQH'></tfoot><dl id='FDTQH'><fieldset id='FDTQH'></fieldset></dl></div>
        • <legend id='FDTQH'><style id='FDTQH'><dir id='FDTQH'><q id='FDTQH'></q></dir></style></legend>
          <tfoot id='FDTQH'></tfoot>

          <small id='FDTQH'></small><noframes id='FDTQH'>

            • <bdo id='FDTQH'></bdo><ul id='FDTQH'></ul>

                1. 本文介绍了不要等待在 Python 中使用 Selenium 加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何让 selenium 在页面完全加载之前点击元素并抓取数据?我的互联网连接非常糟糕,所以有时需要很长时间才能完全加载页面,这有什么问题吗?

                  How do I make selenium click on elements and scrape data before the page has fully loaded? My internet connection is quite terrible so it sometimes takes forever to load the page entirely, is there anyway around this?

                  推荐答案

                  ChromeDriver 77.0(支持 Chrome 77 版)现在支持 eager作为 pageLoadStrategy.

                  ChromeDriver 77.0 (which supports Chrome version 77) now supports eager as pageLoadStrategy.

                  已解决的问题 1902:支持急切页面加载策略 [Pri-2]

                  Resolved issue 1902: Support eager page load strategy [Pri-2]

                  <小时>

                  当你提到在页面完全加载之前点击元素并抓取数据在这种情况下,我们可以利用属性pageLoadStrategy.当 Selenium 默认加载页面/url 时,它遵循默认配置,将 pageLoadStrategy 设置为 normal.Selenium 可以从不同的文档就绪状态开始执行下一行代码.目前 Selenium 支持 3 种不同的 Document readiness state,我们可以通过 pageLoadStrategy 配置如下:


                  As you question mentions of click on elements and scrape data before the page has fully loaded in this case we can take help of an attribute pageLoadStrategy. When Selenium loads a page/url by default it follows a default configuration with pageLoadStrategy set to normal. Selenium can start executing the next line of code from different Document readiness state. Currently Selenium supports 3 different Document readiness state which we can configure through the pageLoadStrategy as follows:

                  1. (未定义)
                  2. eager(页面变为交互式)
                  3. 正常(完成页面加载)

                  这是配置pageLoadStrategy的代码块:

                  Here is the code block to configure the pageLoadStrategy:

                  from selenium import webdriver
                  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
                  
                  binary = r'C:Program FilesMozilla Firefoxfirefox.exe'
                  caps = DesiredCapabilities().FIREFOX
                  # caps["pageLoadStrategy"] = "normal"  #  complete
                  caps["pageLoadStrategy"] = "eager"  #  interactive
                  # caps["pageLoadStrategy"] = "none"   #  undefined
                  driver = webdriver.Firefox(capabilities=caps, firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")
                  driver.get("https://google.com")
                  

                  这篇关于不要等待在 Python 中使用 Selenium 加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  <tfoot id='zm3go'></tfoot>

                  <small id='zm3go'></small><noframes id='zm3go'>

                  <legend id='zm3go'><style id='zm3go'><dir id='zm3go'><q id='zm3go'></q></dir></style></legend>
                  • <bdo id='zm3go'></bdo><ul id='zm3go'></ul>
                    <i id='zm3go'><tr id='zm3go'><dt id='zm3go'><q id='zm3go'><span id='zm3go'><b id='zm3go'><form id='zm3go'><ins id='zm3go'></ins><ul id='zm3go'></ul><sub id='zm3go'></sub></form><legend id='zm3go'></legend><bdo id='zm3go'><pre id='zm3go'><center id='zm3go'></center></pre></bdo></b><th id='zm3go'></th></span></q></dt></tr></i><div id='zm3go'><tfoot id='zm3go'></tfoot><dl id='zm3go'><fieldset id='zm3go'></fieldset></dl></div>

                            <tbody id='zm3go'></tbody>