久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <small id='bceM7'></small><noframes id='bceM7'>

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

  2. <tfoot id='bceM7'></tfoot><legend id='bceM7'><style id='bceM7'><dir id='bceM7'><q id='bceM7'></q></dir></style></legend>

      如何在每個請求上使用 selenium python 輪換各種用戶

      How to rotate various user agents using selenium python on each request(如何在每個請求上使用 selenium python 輪換各種用戶代理)
    1. <i id='mdvoL'><tr id='mdvoL'><dt id='mdvoL'><q id='mdvoL'><span id='mdvoL'><b id='mdvoL'><form id='mdvoL'><ins id='mdvoL'></ins><ul id='mdvoL'></ul><sub id='mdvoL'></sub></form><legend id='mdvoL'></legend><bdo id='mdvoL'><pre id='mdvoL'><center id='mdvoL'></center></pre></bdo></b><th id='mdvoL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mdvoL'><tfoot id='mdvoL'></tfoot><dl id='mdvoL'><fieldset id='mdvoL'></fieldset></dl></div>
        <bdo id='mdvoL'></bdo><ul id='mdvoL'></ul>

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

              <tbody id='mdvoL'></tbody>
          • <small id='mdvoL'></small><noframes id='mdvoL'>

              • <tfoot id='mdvoL'></tfoot>
                本文介紹了如何在每個請求上使用 selenium python 輪換各種用戶代理的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我想向 python 客戶端.


                最初回答于 2018 年 11 月 6 日 8:00

                .當您使用 ChromeOptions 配置 ChromeDriver 實例以啟動新的 Chrome 瀏覽器會話 時,ChromeDriver 的配置在 ChromeDriver 的整個生命周期中保持不變并且保持不可編輯.因此,當 WebDriver 實例執行循環發出 10 個請求時,您無法更改 用戶代理.

                即使您能夠提取 ChromeDriverChromeSession 屬性,例如UserAgentSession IDCookies 和已啟動的瀏覽會話中的其他會話屬性,您仍然不會能夠更改 ChromeDriver 的那些屬性.

                更簡潔的方法是在 tearDown(){} 方法中調用 driver.quit()closedestroy 優雅地 ChromeDriverChrome Browser 實例,然后跨越一組新的 ChromeDriverChrome 瀏覽器 具有新配置集的實例.

                您可以在此處找到有關 如何用 selenium 重新連接到 webdriver 打開的瀏覽器?


                參考

                您可以在以下位置找到一些相關的詳細討論:

                • 如何更改用戶使用 Selenium 和 Python 的代理
                • Selenium webdriver:修改導航器.webdriver 標志以防止硒檢測

                I want to make 10 requests to https://www.google.com/ but with random user agents using selenium and python. I've a loop and inside that loop I'm making 10 requests with random user agents (using fake-user agent). The main problem is for every request web driver is opening a new instance of google chrome and I want to do this in one single instance but with different user agents. How can I make this possible ? 1 google chrome instance and 10 requests with 10 random user agents. Here is my code:

                chrome_options = Options()
                chrome_options.add_argument('no-sandbox')
                chrome_options.add_argument("--start-maximized")
                ua = UserAgent()
                for i in range(0, 10):
                    userAgent = ua.random
                    chrome_options.add_argument('--user-agent="' + str(userAgent) + '"')
                    driver1 = webdriver.Chrome(chrome_options=chrome_options, 
                    executable_path="C:/Python34/chromedriver")
                    driver1.get('https://www.google.com/')
                    time.sleep(5)
                

                解決方案

                First the update 1

                execute_cdp_cmd(): With the availability of execute_cdp_cmd(cmd, cmd_args) command now you can easily execute google-chrome-devtools commands using Selenium. Using this feature you can modify the user-agent easily to prevent Selenium from getting detected.

                • Code Block:

                  from selenium import webdriver
                  
                  driver = webdriver.Chrome(executable_path=r'C:WebDriverschromedriver.exe')
                  print(driver.execute_script("return navigator.userAgent;"))
                  # Setting user agent as Chrome/83.0.4103.97
                  driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'})
                  print(driver.execute_script("return navigator.userAgent;"))
                  # Setting user agent as Chrome/83.0.4103.53
                  driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36'})
                  print(driver.execute_script("return navigator.userAgent;"))
                  driver.get('https://www.httpbin.org/headers')
                  

                • Console Output:

                  Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36
                  Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36
                  Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36
                  

                • Browser Snapshot:

                Legend: 1 - Applicable only to Selenium python clients.


                Originally answered Nov 6 '18 at 8:00

                No. When you configure an instance of a ChromeDriver with ChromeOptions to initiate a new Chrome Browser Session the configuration of the ChromeDriver remains unchanged throughout the lifetime of the ChromeDriver and remains uneditable. So you can't change the user agent when the WebDriver instance is executing the loop making 10 requests.

                Even if you are able to extract the ChromeDriver and ChromeSession attributes e.g. UserAgent, Session ID, Cookies and other session attributes from the already initiated Browsing Session still you won't be able to change those attributes of the ChromeDriver.

                A cleaner way would be to call driver.quit() within tearDown(){} method to close and destroy the ChromeDriver and Chrome Browser instances gracefully and then span a new set of ChromeDriver and Chrome Browser instance with the new set of configurations.

                Here you can find a relevant discussion on How can I reconnect to the browser opened by webdriver with selenium?


                Reference

                You can find a couple of relevant detailed discussions in:

                • How to change the User Agent using Selenium and Python
                • Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection

                這篇關于如何在每個請求上使用 selenium python 輪換各種用戶代理的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                message.channel.id Discord PY(message.channel.id Discord PY)
                How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                  <tbody id='sBWJI'></tbody>
                  • <bdo id='sBWJI'></bdo><ul id='sBWJI'></ul>
                    <tfoot id='sBWJI'></tfoot>

                  • <small id='sBWJI'></small><noframes id='sBWJI'>

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

                          主站蜘蛛池模板: 国产男女猛烈无遮掩视频免费网站 | 国产精品一区在线 | 在线视频 亚洲 | 免费成人av | 在线视频亚洲 | 国产精品免费高清 | 羞羞视频免费观看 | 一区二区三区视频在线观看 | 一二区视频 | 在线观看电影av | 99在线免费观看视频 | 免费在线播放黄色 | 国产999精品久久久久久 | 国产高清一区二区三区 | 精品av| 国产日产精品一区二区三区四区 | 国产精品免费看 | 亚洲狠狠丁香婷婷综合久久久 | 一区二区三区不卡视频 | 91久久夜色精品国产网站 | 日韩欧美成人精品 | a级毛片国产 | 夜久久| 国产精品一区二 | 久久久久久久久蜜桃 | 久久精品国产一区二区电影 | 亚洲视频中文字幕 | 粉嫩在线 | 亚洲一区二区三区视频免费观看 | 中文字幕亚洲视频 | 日韩视频免费 | 国产精品区二区三区日本 | 精品久久久久久中文字幕 | 日韩欧美精品在线 | 一级片在线观看视频 | 无码日韩精品一区二区免费 | 亚洲精品久久久久中文字幕二区 | 欧洲尺码日本国产精品 | 91天堂| 欧美成人免费电影 | 久久久久久久久久久丰满 |