<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                為什么要動態加載? 有些網站的數據是通過異步加載的,需要等待一定的時間后才能抓取到網頁的html結構,所以我們需要等待一定的時間才能從捕捉到我們想要的數據。 <br/> 實現步驟如下:就是定義個中間件 **1. 在`middlewares.py`中定義 SeleniumMiddleware 中間件** ```python class SeleniumMiddleware: def process_request(self, request, spider): url = request.url # 使用selenium是非常消耗內存的,所以我們只在需要動態加載的url中進行加載 if 'booksort' in url: driver = webdriver.Chrome() driver.get(url) time.sleep(3) # 提醒:page_source是獲取等待一定時間后的網頁源碼,不是獲取靜態頁面的源碼 data = driver.page_source driver.close() # 創建響應對象 res = HtmlResponse(url=url, body=data, encoding='utf-8', request=request) return res return None def process_response(self, request, response, spider): return response ``` <br/> **2. 在`settings.py`中啟動 SeleniumMiddleware 中間件** ```python DOWNLOADER_MIDDLEWARES = { "jdbookspro.middlewares.SeleniumMiddleware": 303, } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看