python - 自动登录 Google 帐户 Python Selenium
问题描述
找不到自动登录 google (gmail) 帐户的任何解决方案。
这是我的代码:
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
opt = Options()
executable_path = r'chromedriver'
os.environ["webdriver.chrome.driver"] = executable_path
opt.add_extension(r'C:\Users\SAMSUNG\Desktop\SB.crx')
opt.add_extension(r'C:\Users\SAMSUNG\Desktop\proxy.crx')
opt.add_argument('--disable-blink-features=AutomationControlled')
opt.add_experimental_option("excludeSwitches", ["enable-automation"])
opt.add_experimental_option('useAutomationExtension', False)
opt.add_argument("window-size=1280,800")
usernameStr = 'x'
passwordStr = 'y'
driver = webdriver.Chrome(r'C:\Users\SAMSUNG\Desktop\chromedriver', options=opt)
time.sleep(5)
driver.get(('https://accounts.google.com/ServiceLogin?'
'service=mail&continue=https://mail.google'
'.com/mail/#identifier'))
# fill in username and hit the next button
username = driver.find_element_by_id('identifierId')
username.send_keys(usernameStr)
time.sleep(2)
nextButton = driver.find_element_by_id('identifierNext')
nextButton.click()
# wait for transition then continue to fill items
password = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.NAME, "password")))
password.send_keys(passwordStr)
signInButton = driver.find_element_by_id('passwordNext')
signInButton.click()
但我不断收到此错误:此浏览器或应用程序可能不安全。了解更多 尝试使用其他浏览器。如果您已经在使用受支持的浏览器,则可以刷新屏幕并再次尝试登录。
解决方案
推荐阅读
- javascript - 如何在顶点图表的多y轴中设置最小值
- python - 具有无序分类变量的 Pandas 交叉表
- mysql - MySQL 无法让 FOREIGN KEY 命令正常工作
- pine-script - 由于 calc_on_order_fills 未正确触发策略退出限制
- upload - 409 上传会话已在使用 - Dailymotion 可恢复上传 api
- build - 将源代码构建的包添加到诗歌
- node.js - 当我运行 `ng new` 时,npm 存在依赖问题
- mysql - 查询以打乱存储在字符串 mysql 数据库列中的带有分隔符的字符串列表
- javascript - 仅反应最后一个映射元素显示正确的变量
- javascript - 我尝试使用链码查询该项目,但它显示 [object object]。我不知道我使用了错误的输入或锁链错误