我試圖在使用最新的 UserAgent 無頭運行時刮掉亞馬遜,但我的速率受到限制。當我 # 退出無頭線路時,我不會被檢測到或速率受限。下面是我的代碼!
options = Options()
options.add_experimental_option("excludeSwitches", ["enable-logging"])
options.add_experimental_option("useAutomationExtension", False)
#options.add_argument("--headless")
options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36")
service = ChromeService(executable_path=ChromeDriverManager().install())
browser = webdriver.Chrome(service=service, options=options)
browser.get("https://www.amazon.com.au/Oculus-Quest-2-Virtual-Reality-Headset/dp/B08FSZ8QWH")
print(browser.page_source)
當我在 options.add_argument("--headless") 洗掉 # 并運行代碼時,我得到一個服務器忙線。有誰知道修復?
uj5u.com熱心網友回復:
為了避免使用檢測谷歌瀏覽器無頭add_argument()通過如下方式添加以下引數:
--disable-blink-features=AutomationControlled
示例代碼:
options = Options()
options.headless = True
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
s = Service('C:\\BrowserDrivers\\chromedriver.exe')
driver = webdriver.Chrome(service=s, options=options)
driver.get("https://www.amazon.com.au/Oculus-Quest-2-Virtual-Reality-Headset/dp/B08FSZ8QWH")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/411719.html
標籤:
