[Python] Google login on Pythonanywhere

Discussão em 'Python' iniciado por Stack, Setembro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using this code to connect remotely to my google account using requests. On local it works perfectly but when I'm trying to use on Pythonanywhere (same version of python 3.6 + I do have a paid account, a hacker plan) it doesn't work, it doesn't connect to my google account at all, without any error message in the console, do you have any idea what could be the problem ?

    from bs4 import BeautifulSoup
    import requests

    class SessionGoogle:
    def __init__(self, url_login, url_auth, login, pwd):
    self.ses = requests.session()
    login_html = self.ses.get(url_login)
    soup_login = BeautifulSoup(login_html.content).find('form').find_all('input')
    my_dict = {}
    for u in soup_login:
    if u.has_attr('value'):
    my_dict[u['name']] = u['value']
    # override the inputs without login and pwd:
    my_dict['Email'] = login
    my_dict['Passwd'] = pwd
    self.ses.post(url_auth, data=my_dict)

    def get(self, URL):
    return self.ses.get(URL).text

    url_login = "https://accounts.google.com/ServiceLogin"
    url_auth = "https://accounts.google.com/ServiceLoginAuth"
    session = SessionGoogle(url_login, url_auth, "myGoogleLogin", "myPassword")
    print session.get("http://plus.google.com")

    Continue reading...

Compartilhe esta Página