使用 Python 获取 SharePoint 列表 [英] Get SharePoint List with Python

查看:38
本文介绍了使用 Python 获取 SharePoint 列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试寻找任何可能的方式在 Python 中获取 SharePoint 列表.我能够通过以下视频连接到 SharePoint 并使用 Rest API 获取 XML 数据:https://www.youtube.com/watch?v=dvFbVPDQYyk...但不确定如何将列表数据导入python.最终目标是每天获取 SharePoint 数据并导入 SSMS.

I am trying to find any way possible to get a SharePoint list in Python. I was able to connect to SharePoint and get the XML data using Rest API via this video: https://www.youtube.com/watch?v=dvFbVPDQYyk... but not sure how to get the list data into python. The ultimate goal will be to get the SharePoint data and import into SSMS daily.

这是我目前所拥有的..

Here is what I have so far..

import requests
from requests_ntlm import HttpNtlmAuth
url='URL would go here'
username='username would go here'
password='password would go here'
r=requests.get(url, auth=HttpNtlmAuth(username,password),verify=False)

我相信这些将是下一步.我真的只需要帮助以 Excel/CSV 格式从 SharePoint 获取数据,并且从那里应该没问题.但任何建议都会有所帮助..

I believe these would be the next steps. I really only need help getting the data from SharePoint in Excel/CSV format preferably and should be fine from there. But any recommendations would be helpful..

#PARSE XML VIA REST API
#PRINT INTO DATAFRAME AND CONVERT INTO CSV
#IMPORT INTO SQL SERVER
#EMAIL RESULTS

推荐答案

from shareplum import Site
from requests_ntlm import HttpNtlmAuth

server_url = "https://sharepoint.xxx.com/"
site_url = server_url + "sites/org/"

auth = HttpNtlmAuth('xxx\user', 'pwd')
site = Site(site_url, auth=auth, verify_ssl=False)
sp_list = site.List('list name in my share point')
data = sp_list.GetListItems('All Items', rowlimit=200)

这篇关于使用 Python 获取 SharePoint 列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆