python mechanize forms() err -


i'm using python 2.7.6 , mechanize 0.2.5 , want log in 'dining.ut.ac.ir' (i have username , password)- when try run below script forms list:

import mechanize br = mechanize.browser() br.set_handle_robots(false) br.addheaders = [('user-agent', 'firefox')]     br.open("http://dining.ut.ac.ir/") br.forms() 

i error:

traceback (most recent call last):   file "script.py", line 8, in <module>     br.forms()   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_mechanize.py", line 420, in forms     return self._factory.forms()   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_html.py", line 557, in forms     self._forms_factory.forms())   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_html.py", line 237, in forms     _urlunparse=_rfc3986.urlunsplit,   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_form.py", line 844, in parseresponseex     _urlunparse=_urlunparse,   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_form.py", line 981, in _parsefileex     fp.feed(data)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_form.py", line 758, in feed     _sgmllib_copy.sgmlparser.feed(self, data)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_sgmllib_copy.py", line 110, in feed     self.goahead(0)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_sgmllib_copy.py", line 144, in goahead     k = self.parse_starttag(i)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_sgmllib_copy.py", line 302, in parse_starttag     self.finish_starttag(tag, attrs)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_sgmllib_copy.py", line 347, in finish_starttag     self.handle_starttag(tag, method, attrs)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_sgmllib_copy.py", line 387, in handle_starttag     method(attrs)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_form.py", line 735, in do_option     _abstractformparser._start_option(self, attrs)   file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_form.py", line 480, in _start_option     raise parseerror("option outside of select") mechanize._form.parseerror: option outside of select 

why error , how can fix it?

the url trying open gzipped (check using this link), have append accept-encoding header gzip browser:

import mechanize br = mechanize.browser() br.set_handle_robots(false) br.addheaders = [('user-agent', 'firefox')] br.addheaders.append( ['accept-encoding','gzip'] ) br.open("http://dining.ut.ac.ir/") br.forms() 

Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -