Thanks for the help!!!
However, I have not been able to solve the problem still. I am a beginner python programmer and so I have little knowledge about it. However, I can understand what's happening by reading a code.
I've changed the code as per your advice. Is it how you wanted now?
import requests,re
import xml.etree.ElementTree as ET
import json
#def getCellTowerInfo():
print ("Logging in to router home page")
baseurl = 'http://192.168.0.1/'
url = baseurl + 'login.asp'
payload = {'ID':'admin','PASSWORD':'admin','REDIRECT':'index.asp','REDIRECT_ERR':'login.asp'}
response = requests.Session()
response = response.post(url, data = json.dumps(payload) )
print (response)
On running this, the error which pops out is...
Error:
Logging in to router home page
Traceback (most recent call last):
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1197, in getresponse
response.begin()
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\adapters.py", line 445, in send
timeout=timeout
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\util\retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 1197, in getresponse
response.begin()
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "get_cell_tower_data.py", line 10, in <module>
response = response.post(url, data = json.dumps(payload) )
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 559, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "C:\Users\DEEP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\adapters.py", line 495, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
I hope you can help further.