I'm trying to use mechanize
module to login to quora.com.
This is my code:
#!/usr/bin/env python
import mechanize
import cookielib
br = mechanize.Browser() # create a browser object
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_headers = [('User-Agent', 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)')]
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
res = br.open('http://www.quora.com')
br.select_form(nr = 0)
br.form['email'] = 'uuuu'
br.form['password'] = 'pppp'
res = br.submit()
print res.read()
I get this error:
Traceback (most recent call last):
File "mech.py", line 29, in <module>
res = br.submit()
File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 541, in submit
return self.open(self.click(*args, **kwds))
File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 203, in open
return self._mech_open(url, data, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 255, in _mech_open
raise response
mechanize._response.httperror_seek_wrapper: HTTP Error 500: Internal Server Error
I know that HTTP 500 means there is something wrong server-side, but I have no idea what it is, and how I can debug the issue.