使用Python登录Google失败

2024-05-04 00:20:28 发布

您现在位置:Python中文网/ 问答频道 /正文

不明白为什么谷歌不让我登录我的账户。我把我的电子邮件放在一个名为my_mail的变量中,然后在html中搜索它,但结果返回false。在

我使用requests&;beautifulsoup模块来执行此操作。在

我所拥有的:

from bs4 import BeautifulSoup
import requests

form_data={'Email': 'ExampleEmail@gmail.com', 'Passwd': 'Password'}
post = "https://accounts.google.com/signin/challenge/sl/password"
my_mail = 'ExampleEmail@gmail.com'

with requests.Session() as s:
    soup = BeautifulSoup(s.get("https://accounts.google.com/ServiceLogin?elo=1").text, "html.parser")
    for inp in soup.select("#gaia_loginform input[name]"):
        if inp["name"] not in form_data:
            form_data[inp["name"]] = inp["value"]
    s.post(post, form_data)

print(my_mail in "https://mail.google.com/mail/u/0/#inbox")

表单信息:

^{pr2}$

我不打算使用谷歌的API。我不想被限制。在

为什么登录失败?我能做些什么来修复它?在

我需要登录来删除一些需要登录的信息。在

普顿3.4.2


Tags: nameinhttpsimportformcomdatamy