Logging in to google using python?

后端 未结 4 532
清酒与你
清酒与你 2020-12-13 11:19

I am fairly new to web programing but for the sake of it, I am trying to login to google account not using standard code but as a python application, but it is impossible to

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 11:45

    2020 update for python 3:

    
    def unread_messages(user, passwd):
        auth_handler = urllib.request.HTTPBasicAuthHandler()
        auth_handler.add_password(
            realm='New mail feed',
            uri='https://mail.google.com',
            user='%s@gmail.com' % user,
            passwd=passwd
        )
        opener = urllib.request.build_opener(auth_handler)
        urllib.request.install_opener(opener)
        feed = urllib.request.urlopen('https://mail.google.com/mail/feed/atom')
        return feed.read()
    
    
    print(unread_messages('username','password')
    

提交回复
热议问题