Login Forms for Hotmail Website using Mechanize/Python -


i'm learning mechanize/beautifulsoup following instruction on site: http://stockrt.github.io/p/handling-html-forms-with-python-mechanize-and-beautifulsoup/

instead of writing login , check mail gmail, want same hotmail. however, cannot find login form using mechanize. result when im trying following empty:

for f in self.br.forms():   print 'form:', f 

those codes print out nothing. inspecting hotmail website (login.live.com) can see form name 'f1' , 2 fields 'username' , 'passwd' mechanize cannot able catch those.

here complete code:

import os import mechanize import cookielib bs4 import beautifulsoup import html2text import agent  class hotmail:     def __init__(self):         self.br = mechanize.browser()         cj = cookielib.lwpcookiejar()     # cookie jar         self.br.set_cookiejar(cj)         # browser options         self.br.set_handle_equiv(true)         #self.br.set_handle_gzip(true)         self.br.set_handle_redirect(true)         self.br.set_handle_referer(true)         self.br.set_handle_robots(false)          self.br.set_handle_refresh(mechanize._http.httprefreshprocessor(), max_time=1)   # follows refresh 0 not hangs on refresh > 0         self.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')]                       # user-agent      def login(self, user, pswd):         self.br.open('http://login.live.com')         f in self.br.forms():             print 'form:', f  if __name__ == '__main__':     test = hotmail()     test.login('asd','asd') 

i tried manually set form 'f1' br.form , fill out values it, doesn't work.

any ideas why mechanize cannot recognize forms on hotmail or how forms?

thank much!


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -