I'm trying to get an excel sheet downloaded using python requests module and getting junk output
Question: I'm trying to download an excel file which is uploaded on a Sharepoint 2013
site.

My code is as follows:

    
    
    import requests
    url='https://<sharepoint_site>/<document_name>.xlsx?Web=0'
    author = HttpNtlmAuth('<username>','<passsword>')
    response=requests.get(url,auth=author,verify=False)
    print(response.status_code)
    print(response.content)
    

This gives me a long output which is something like:

>
> x00docProps/core.xmlPK\x01\x02-\x00\x14\x00\x06\x00\x08\x00\x00\x00!\x00\x7f\x8bC\xc3\xc1\x00\x00\x00"\x01\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8\xb9\x01\x00customXml/item1.xmlPK\x05\x06\x00\x00\x00\x00\x1a\x00\x1a\x00\x12\x07\x00\x00\xd2\xba\x01\x00\x00\x00'

I did something like this before for another site and I got xml as output
which was acceptable for me but I'm not sure how to handle this data.

Any ideas to process this to be like xlsx or xml?

Or maybe to download the xlsx another way?(I tried doing it through the wget
library and the excel seems to get corrupted)

Any ideas would be really helpful.

Regards, Karan


Answer: It seems that the file is encrypted and request can't handle this.  
Maybe the web service provides an API for downloading and secure decoding.

