I'm trying to open a secure (https) website using mechanize library in Python. When I try to access the website, the server closes the connection and exception BadStatusLine is raised.
I have tried to modify the headers using the addheaders
property, but no response.
import mechanize
br = mechanize.Browser()
print 'opening page ...'
resp = br.open('https://onlineservices.tin.nsdl.com/etaxnew/tdsnontds.jsp') #this one works fine
print 'ok'
print 'opening page 2 ...'
resp = br.open('https://incometaxindiaefiling.gov.in/portal/index.do') #exception raised
print 'ok'
Exception:
Traceback (most recent call last): File pydev_imports.execfile(file, globals, locals) #execute the script File "Z:\pyTax\app_test.py", line 22, in resp=br.open('https://incometaxindiaefiling.gov.in/portal/index.do')
File "build\bdist.win32\egg\mechanize_mechanize.py", line 203, in open File "build\bdist.win32\egg\mechanize_mechanize.py", line 230, in _mech_open File "build\bdist.win32\egg\mechanize_opener.py", line 188, in open File "build\bdist.win32\egg\mechanize_http.py", line 316, in http_request File "build\bdist.win32\egg\mechanize_http.py", line 242, in read File "build\bdist.win32\egg\mechanize_mechanize.py", line 203, in open
File "build\bdist.win32\egg\mechanize_mechanize.py", line 230, in _mech_open File "build\bdist.win32\egg\mechanize_opener.py", line 193, in open File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 344, in _open File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 332, in _call_chain File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 1170, in https_open File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 1116, in do_open File "D:\Python27\lib\httplib.py", line 1031, in getresponse response.begin() File "D:\Python27\lib\httplib.py", line 407, in begin version, status, reason = self._read_status() File "D:\Python27\lib\httplib.py", line 371, in _read_status raise BadStatusLine(line) httplib.BadStatusLine: ''