简体   繁体   English

Selenium - 如何指向现有的登录数据

[英]Selenium - How to point to existing log-in data

I am building a scraper for a site using Selenium (VBA & Chromedriver).我正在使用 Selenium(VBA 和 Chromedriver)为网站构建一个刮板。 The problem is, I need to log into this site and stay logged in. With my 'normal' browser session, the log-in remains.问题是,我需要登录该站点并保持登录状态。使用我的“普通”浏览器 session,登录仍然存在。 In selenium, I understand that this is not the case and I need to 'add a cookie' or something.在 selenium 中,我知道情况并非如此,我需要“添加 cookie”或其他内容。

I would like to not log in programmatically and save a cookie.不想以编程方式登录并保存 cookie。 That seems silly.这似乎很愚蠢。 Because my 'normal' browser already has these details saved SOMEWHERE (AppData??).因为我的“普通”浏览器已经将这些详细信息保存在某处(AppData??)。 I just don't know how to point this info to my Selenium driver in code.我只是不知道如何在代码中将此信息指向我的 Selenium 驱动程序。 Any help is appreciated.任何帮助表示赞赏。

Solved.解决了。 To point the driver to your 'actual' chrome's user data:要将驱动程序指向“实际”chrome 的用户数据:

driver.AddArgument ("user-data-dir=C:\Users\USERNAME\AppData\Local\Google\Chrome\User Data")

source: HERE来源: 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM