机械化/OWA用户/密码错误 [英] Mechanize/OWA user/password error

查看:89
本文介绍了机械化/OWA用户/密码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Mechanize从Outlook Web客户端获取电子邮件,但登录时遇到麻烦.它给我列出了以下错误.我已验证用户名和密码正确.有什么想法吗?

I'm trying to use Mechanize to get emails from my Outlook web client, but I'm having troubles logging in. It gives me the errors listed below. I've verified that the user name and password are correct. Any ideas?

这是我的代码:

import mechanize

b = mechanize.Browser()
cj = cookielib.LWPCookieJar()
b.set_cookiejar(cj)

b.open('https://mail.example.com/owa/')
br.select_form("logonForm")
b['username'] = 'myname'
b['password'] = 'password'
b.submit()

我可以看到正在正确访问表单组件,但是提交后,登录页面再次显示,但有两个错误:

I can see that form components are being accessed correctly, but after submitting, the login page displays again with two errors:

  1. 您输入的用户名或密码不正确.尝试再次输入.
  2. 请为此网站启用cookie.

我认为b.set_cookiejar(cj)会处理cookie.这可能是我问题的根源吗?

I thought the b.set_cookiejar(cj) would take care of cookies. Could this be the root of my problem?

推荐答案

import mechanize 
import cookielib

br = mechanize.Browser()
br.set_handle_robots( False )
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]

br.open('https://webmail.server.com')
br.select_form(nr = 0) 
br.form['username'] = 'username'
br.form['password'] = 'password'
br.submit()

使用它对我有用

这篇关于机械化/OWA用户/密码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆