1

I need to open the page automatically and download the file returned by the server

I have a simple code to open the page and download the content. I am also pulling the headers so I know the name of the returned file. below is the code

downloadPageRequest = self.reqSession.get( self.url_file ,stream=True)
headers = downloadPageRequest.headers

if 'content-disposition' in headers:
    file_name = re.findall("filename=(.+)", headers['content-disposition'])

that's what I got, it returns an array with the filename, but now I am stuck and have no idea how to open and go through returned excel file

this has to be done using requests, that's why i cannot use any other method (e.g selenium)

will be thankful for your support

js_beghlp
  • 27
  • 5
  • Does https://stackoverflow.com/a/39217788/1073696 help? – brunns Apr 24 '19 at 13:57
  • no, unfortunately it saves a file, but the content is different, looks like random ascii characters – js_beghlp Apr 24 '19 at 14:04
  • this thread solved my problem https://stackoverflow.com/questions/39147330/im-trying-to-get-an-excel-sheet-downloaded-using-python-requests-module-and-get – js_beghlp Apr 24 '19 at 14:16

0 Answers0