- How to access a password protected site using python?
- yahoo_mail = 'http://mail.cn.yahoo.com'
- br = mechanize.Browser()
- r = br.open(yahoo_mail)
- print r.info() #here, I got 200, it's ok apparently
- br.select_form(nr=0) #select the login form
- r = br.submit() #submit the form without providing username and password
- print r.info() #but I didn't get 401, why?
- f = open('a.html', 'w')
- f.write(r.read())