I am trying to download excel files from my work SharePoint site to a local folder using python. I have written a code to successfully authenticate into the sharepoint site.But need help in downloading the Excel files from the sharepoint document library. I am new to Python and would really appreciate your help :) Below is my code :
import urllib.request
import requests
from requests_ntlm import HttpNtlmAuth
def sharepointlogin():
site = "https://abc.sharepoint.com/site"
username = "*******"
password = "*******"
response = requests.get(site, auth=HttpNtlmAuth(username, password))
print(response.status_code)
def filedownload():
print('Downloading file')
url = 'https://abc.sharepoint.com'
urllib.request.urlretrieve(url, 'C:\Downloads\filename.xlsx')
print("File Downloaded")
print("Download complete")
sharepointlogin()
filedownload()