Reputation: 411
I want to save locally the configuration file from my cable modem. I already have logged into the html admin page of the modem and inside the backup page, there is a button to backup the configuration file. Inside the event, there is a POST method on the form that leads to the next url:
https://192.168.1.1/goform/BackUp
The response headers are:
HTTP/1.0 200 OK
Server: GoAhead-Webs
Pragma: no-cache
Cache-control: no-cache
Content-Type: application/download
Content-Disposition: attachment; filename=cmconfig.cfg // This is the file that is downloaded when I click in the BackUp button
And this are the parameters that I pass to the POST function:
dir: admin/
file: cmconfig.cfg
So far, I have this code:
with requests.Session() as s: # To login into the modem
pagePostBackUp = 'https://192.168.1.1/goform/BackUp'
s.post(urlLogin, data=loginCredentials, verify=False, timeout=5)
dataBackUp = {'dir': 'admin/','file': 'cmconfig.cfg'}
resultBackUp = s.post(pagePostBackUp, data=dataBackUp, verify=False, timeout=10)
What should be the next line to save the cmconfig.cfg
file locally?
Upvotes: 1
Views: 61
Reputation: 3957
Your resultBackUp
is a response object, so you could use its text
or json
methods.
print(resultBackUp.text)
Upvotes: 1