要获取SharePoint文件列表,您可以使用shareplum库来连接到SharePoint,并使用get_folder方法来获取文件列表。

首先,您需要安装shareplum库。您可以使用以下命令安装它:

pip install shareplum

然后,您可以使用以下代码获取SharePoint文件列表:

from shareplum import Site
from shareplum import Office365

# SharePoint网站的URL和凭据
sharepoint_url = "https://your-sharepoint-site-url"
username = "your-username"
password = "your-password"

# 使用Office365身份验证连接到SharePoint
authcookie = Office365(sharepoint_url, username=username, password=password).GetCookies()
site = Site(sharepoint_url, authcookie=authcookie)

# 获取文件列表
folder = site.Folder('Shared Documents')  # 替换为您的文件夹路径
files = folder.get_list_items()

# 打印文件列表
for file in files:
    print(file['FileLeafRef'])

请注意,您需要将上述代码中的"your-sharepoint-site-url"替换为您的SharePoint网站的URL,并将"your-username"和"your-password"替换为您的凭据。

此外,您还需要将folder变量中的'Shared Documents'替换为您想要获取文件列表的文件夹路径

python 获取sharepoint 文件列表

原文地址: https://www.cveoy.top/t/topic/hLEM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录