您可以使用HTTPBasicAuthHandler,我尝试了以下 *** 作并成功运行:
import urllib2def get_unread_msgs(user, passwd): auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler.add_password( realm='New mail feed', uri='https://mail.google.com', user='%s@gmail.com' % user, passwd=passwd ) opener = urllib2.build_opener(auth_handler) urllib2.install_opener(opener) feed = urllib2.urlopen('https://mail.google.com/mail/feed/atom') return feed.read()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)