import argparse import urllib.parse import os import requests from requests.auth import HTTPBasicAuth auth = HTTPBasicAuth('username', 'password') headers = {'accept': 'application/json;odata=verbose'} def download_file(filename): filename = filename.strip('/') print('Downloading\t'+filename) r = requests.get('https://xxx.sharepoint.com/'+"_api/Web/GetFileByServerRelativeUrl('/Shared Documents/Folderunderdocument/"+'filename.csv'+"')/$value", auth=auth, stream=True) with open(filename, 'wb+') as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) f.flush() if __name__ == '__main__': download_file('filename.csv')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)