简体   繁体   English

如何使用 Google Chrome 而不是 Chromedriver Python Selenium

[英]How do I use Google Chrome instead of Chromedriver Python Selenium

Since chromedriver cannot remember searches history nor does it save cookies... I want to use GoogleChrome, my original browser in Python Selenium, because I want to bypass Hcaptcha, and I have everything set in my original browser to do so.由于 chromedriver 无法记住搜索历史记录,也不保存 cookie...我想使用 GoogleChrome,我在 Python Selenium 中的原始浏览器,因为我想绕过 Hcaptcha,并且我在原始浏览器中设置了所有内容。

Answers are very much appreciated, I am quite new to this so please write in details so that I can understand and show me how to do stuff, much love!非常感谢答案,我对此很陌生,所以请详细写下,以便我理解并告诉我如何做,非常喜欢! :) :)

You can do this by providing your chrome profile to the selenium.您可以通过向 selenium 提供您的 chrome 配置文件来做到这一点。

First type this into your chrome address bar chrome://version/ and copy the profile path.首先在您的 chrome 地址栏中输入chrome://version/并复制配置文件路径。

Note :- Remove the Default from the path ie if the path is /home/aditya/.config/google-chrome/Default then after removing the Default, the path will be /home/aditya/.config/google-chrome注意:- 从路径中删除默认值,即如果路径是/home/aditya/.config/google-chrome/Default然后在删除默认值后,路径将是/home/aditya/.config/google-chrome

then paste the profile path into the following code :-然后将配置文件路径粘贴到以下代码中:-

options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=/home/aditya/.config/google-chrome") # profile path
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://www.google.com")

did you specify your driver?你指定了你的驱动程序吗? if not this might help :)如果不是,这可能会有所帮助:)

from selenium import webdriver从硒导入网络驱动程序

PATH = "C:\\Program Files (x86)\\chromedriver.exe" PATH = "C:\\Program Files (x86)\\chromedriver.exe"

driver = webdriver.Chrome(PATH)驱动程序 = webdriver.Chrome(路径)

暂无
暂无

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

相关问题 如何更改选择器以使网站显示登录而不是使用 selenium python 和 chromedriver 进行注册? - How do I change the selector so that the website shows login instead of signup using selenium python and chromedriver? 如何使用 selenium ChromeDriver 在 Google 地图上滚动侧边栏以加载更多结果? - How do I use selenium ChromeDriver to scroll the sidebar on Google maps to load more results? 弃用警告:在 Python Selenium 和 Windows 上使用 Brave 浏览器时使用选项而不是 chrome_options 错误 - DeprecationWarning: use options instead of chrome_options error using Brave Browser With Python Selenium and Chromedriver on Windows 如何使用 Selenium python 在 google Chrome 中打开 DevTools? - How do I open the DevTools in google Chrome using Selenium python? 使用 Selenium Chromedriver 和 python 我如何点击这个元素? - Using Selenium Chromedriver with python how do i click this element? 如何在常规 chrome 而不是 chromedriver 中运行 selenium 代码? - how to run selenium code in regular chrome instead of chromedriver? Python/Selenium/Chromedriver:脚本只打开一个空白的 Google Chrome 页面 - Python/Selenium/Chromedriver: the script opens just a blank Google Chrome page 有没有办法将 selenium 与 chrome 而不是 chromedriver 一起使用? - Is there a way to use selenium with chrome and NOT chromedriver? Python Selenium如何使用现有的chromedriver窗口? - Python Selenium how to use an existing chromedriver window? 如何在python中将现有的Google Chrome配置文件与Selenium Chrome Webdriver一起使用? - How to use an existing google chrome profile with selenium chrome webdriver in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM