测试 selenium 附加到浏览器

This commit is contained in:
shikong 2024-03-02 03:24:19 +08:00
parent c3c1e6ccc4
commit f2fc675d51
2 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ if __name__ == '__main__':
options.add_argument('lang=zh-CN')
options.add_argument(
'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36')
# options.add_argument('--user-data-dir=./UserData/Google/Chrome/Default')
# options.add_argument(r'--user-data-dir=E:\Repository\skcks.cn\python-selenium-spider\tmp\UserData')
options.add_argument('--disable-gpu') # 如果不加这个选项,有时定位会出现问题
# options.add_argument('--headless') # 增加无界面选项
@ -22,7 +22,7 @@ if __name__ == '__main__':
# })
# """
# })
try:
with open("./stealth.min.js") as f:
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 KiB

After

Width:  |  Height:  |  Size: 315 KiB