修正反爬代码

This commit is contained in:
g1879 2021-01-28 11:46:52 +08:00
parent 1c2b20aea5
commit 1cec593304

View File

@ -121,14 +121,15 @@ class Drission(object):
print('无法启动请检查chromedriver版本与Chrome是否匹配并手动设置。')
exit(0)
# 反爬设置,似乎没用
self._driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": """
Object.defineProperty(navigator, 'webdriver', {
get: () => Chrome
})
"""
})
# 反爬设置
try:
self._driver.execute_script('Object.defineProperty(navigator,"webdriver",{get:() => Chrome,});')
except:
pass
# self._driver.execute_cdp_cmd(
# 'Page.addScriptToEvaluateOnNewDocument',
# {'source': 'Object.defineProperty(navigator,"webdriver",{get:() => Chrome,});'})
return self._driver