問題描述
我嘗試使用 Gmail 或任何 Google 服務(wù)登錄,但它顯示以下此瀏覽器或應(yīng)用程序可能不安全";留言:
I've tried login with Gmail or any Google services but it shows the following "This browser or app may not be secure" message:
我還嘗試在我的賬戶中啟用安全性較低的應(yīng)用等選項(xiàng),但沒有成功.然后我創(chuàng)建了一個(gè)新的谷歌帳戶,它對(duì)我有用.但不是我的舊賬戶.
I also tried to do options like enable less secure app in my acc but it didn't work. then I made a new google account and it worked with me. but not with my old acc.
- 我該如何解決這個(gè)問題?
- 如何在普通的 chrome 瀏覽器中打開 selenium,而不是由自動(dòng)化軟件控制的瀏覽器?
這是我的代碼
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.
First of all don't use chrome and chromedriver. You need to use Firefox.(if not installed) Download and install Firefox. Login to Google with normal Firefox.
您需要向 Google 網(wǎng)站表明您不是機(jī)器人.你可以使用這樣的代碼:
You need to show the Google site that you are not a robot. You can use code like this:
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)
這 可以幫助您找到您的個(gè)人資料位置.
This can help you find your profile location.
其實(shí)只有一個(gè)原因,chromedriver 是谷歌編碼的.他們可以很容易地理解它是否是機(jī)器人.但是當(dāng)我們用 Firefox 添加用戶數(shù)據(jù)時(shí),他們無法理解是否存在 bot.
Actually there is only one reason, chromedriver was coded by Google. They can easily understand if it is a bot or not. But when we add user data with Firefox, they cannot understand if there is a bot or not.
你可以這樣欺騙 Google.它也對(duì)我有用.我非常努力地做到這一點(diǎn).希望它也能在你身上得到解決.
You can fool Google like this. It worked for me too. I tried very hard to do this. Hope it will be resolved in you too.
這篇關(guān)于使用 python 和 selenium 進(jìn)行自動(dòng)化 Google 登錄顯示“"此瀏覽器或應(yīng)用程序可能不安全“"的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!