讓selenium規避網站的檢測


在使用selenium對某些網站模擬訪問的時候會被檢測出來,檢測出來之后就有可能拿不到我們想要的數據,那么我們怎么可以規避掉呢?

在使用谷歌瀏覽器的時候我們右鍵-檢查-console-輸入window.navigator.webdriver假如返回的是True則是被檢測出了了,返回的是undefined則沒檢測到。

from selenium import webdriver
from selenium.webdriver import ChromeOptions
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])

#實例化一個瀏覽器對象
bro = webdriver.Chrome(executable_path='your driver path',options=option)
bro.get('https://www.taobao.com/')

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM