使用Python下载SharePoint文件夹

时间:2015-04-16 16:35:07

标签: python-3.x sharepoint python-requests

我在python中使用请求库从SharePoint 2010获取页面并且它正常工作,现在我需要遍历SharePoint目录并将所有文件从那里下载到我的本地计算机。理想情况下,我会将其映射为计算机上的驱动器,但此选项不在桌面上。我如何使用python实现这一目标?

def __init__(self, url, domain, username, password):
    self.domain = domain
    self.username = username
    self.password = password
    self.url = url
    self.session = requests.Session()
    self.request = None
    self.authentication = HttpNtlmAuth(("%s\\%s" % (self.domain,
                                                    self.username)),
                                       self.password)
    self.headers = {'accept': 'application/json;odata=verbose'}
    self.request_page(self.url)

def request_page(self, url):
    relative_url = urljoin(self.url, url)
    print(relative_url)
    self.request = self.session.get(relative_url,
                                    auth=self.authentication,
                                    headers=self.headers)

0 个答案:

没有答案