[英]how to log in to the google account using selenium python
我一直在嘗試使用 selenium 登錄我的谷歌帳戶,但是一旦我傳入 email 並按回車鍵,它就會重定向到以下消息
“此瀏覽器或應用程序可能不安全。了解更多嘗試使用其他瀏覽器。如果您已經在使用受支持的瀏覽器,則可以刷新屏幕並再次嘗試登錄。”
這是我的 python 代碼:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
options = webdriver.ChromeOptions()
options.add_argument("--enable-javascript")
driver = webdriver.Chrome(executable_path='path/to/chrome/driver',chrome_options = options)
url = "https://accounts.google.com/signin"
driver.get(url)
username = 'email'
password = 'password'
email_phone = driver.find_element_by_id('identifierId')
email_phone.send_keys(username)
email_phone.send_keys(Keys.RETURN)
email_phone = driver.find_element_by_id('password')
email_phone.send_keys(password)
email_phone.send_keys(Keys.RETURN)
請注意,我是 python 和 selenium 的新手。 非常感謝您的幫助。 先感謝您
我嘗試使用Selenium Google 登錄塊中描述的方法,但它仍然給了我相同的消息
更新:截至 2021 年 1 月,這不再有效。
我知道這是一個很晚的答案,但是 Selenium 已經可以做到這一點(通過利用旁路)。
默認情況下,Google 會檢測並有效阻止來自 Selenium webdriver 的所有登錄。
以下鏈接來自Google OAuth Playground,保證鏈接的實用性。 它很可能不會很快到期。
您可以使用該鏈接(即driver.get()
)登錄您的 Google 帳戶。
這繞過了自動化檢查,允許您使用 Selenium 登錄 Google。 至少現在。
如果這對您有幫助,請將其標記為已接受的答案。 它將幫助其他有這個問題的人。
更新:截至 2021 年 1 月,這不再有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.