我试图在使用最新的 UserAgent 进行无头运行时抓取 Amazon,但我的速率受到限制。当我退出无头线路时,我不会被检测到或受到速率限制。下面是我的代码!
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") 处的 # 并运行代码时,我得到服务器忙线。有谁知道修复方法吗?
To 避免被发现 using 谷歌浏览器无头添加以下参数通过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")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)