要使用Python下载SharePoint列表,您需要使用shareplum
库
pip install shareplum
接下来,使用以下示例代码下载SharePoint列表:
from shareplum import Site
from shareplum import Office365
from shareplum.site import Version
# 更新这些信息
server_url = "https://your-sharepoint-site-url"
site_name = "your-site-name"
list_name = "your-list-name"
username = "your-username"
password = "your-password"
# 连接到SharePoint站点
authcookie = Office365(server_url, username=username, password=password).GetCookies()
site = Site(server_url, version=Version.v365, authcookie=authcookie)
# 获取列表
sp_list = site.List(list_name)
# 下载列表的所有项
items = sp_list.GetListItems()
# 打印列表项
for item in items:
print(item)
请确保将server_url
,site_name
,list_name
,username
和password
替换为您的实际SharePoint站点信息。运行此代码后,您应该会看到SharePoint列表中的所有项。
注意:这个示例仅适用于SharePoint Online。如果您需要在SharePoint Server(本地)上执行此操作,请使用shareplum
库的Site
类的Version.v2016
(或更高版本)。
没有搜到相关的文章