我尝试使用 Gmail 或任何 Google 服务登录,但显示以下“此浏览器或应用程序可能不安全”消息:
我还尝试执行诸如在我的 acc 中启用不太安全的应用程序之类的选项,但它不起作用。
然后我创建了一个新的谷歌帐户,它对我有用。但我的旧配件不行。
-
我该如何解决这个问题?
-
我怎样才能在普通的chrome浏览器中打开selenium而不是由自动化软件控制的浏览器
?
这是我的代码
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
browser = webdriver.Chrome()
browser.get('https://accounts.google.com/servicelogin')
search_form = browser.find_element_by_id("identifierId")
search_form.send_keys('mygmail')
nextButton = browser.find_elements_by_xpath('//*[@id ="identifierNext"]')
search_form.send_keys('password')
nextButton[0].click()
首先不要使用chrome和chromedriver。您需要使用Firefox。(如果未安装)下载并安装Firefox。使用普通 Firefox 登录 Google。
您需要向 Google 网站表明您不是机器人。您可以使用这样的代码:
from selenium import webdriver
import geckodriver_autoinstaller
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
geckodriver_autoinstaller.install()
profile = webdriver.FirefoxProfile(
'/Users/<user name>/Library/Application Support/Firefox/Profiles/xxxxx.default-release')
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
desired = DesiredCapabilities.FIREFOX
driver = webdriver.Firefox(firefox_profile=profile,
desired_capabilities=desired)
This https://www.howtogeek.com/255587/how-to-find-your-firefox-profile-folder-on-windows-mac-and-linux/#:%7E:text=The%20default%20locations%20are%3A,%2FFirefox%2FProfiles%2Fxxxxxxxx.可以帮助您找到您的个人资料位置。
但是,为什么是火狐呢?
其实只有一个原因,chromedriver是由Google编码的。
他们可以轻松了解它是否是机器人。但是当我们用 Firefox 添加用户数据时,他们无法了解是否存在机器人。
你可以像这样愚弄谷歌。这对我也有用。我非常努力地去做这件事。希望你也能解决这个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)