简体   繁体   中英

With python, how can I connect to and download files from, a WebDAV server?

My school has a webdav file server that contains files that I frequently need to download. For this server, I have a username and password that I can use to connect to the server, and If I go to the URL in chrome I can view everything just fine. Now my question is, how can I access and login to this WebDAV server with python, and then download files from it. I have been unable to find anything with google and apologize if there was a very simple solution that I missed.

You can use python-webdav-library

from webdav import WebdavClient
url = 'https://somesite.net'
mydav = WebdavClient.CollectionStorer(url, validateResourceNames=False)
mydav.connection.addBasicAuthorization(<username>, <password>)

mydav.path = <path to file I want, ie '/a/b/c.txt'>
mydav.downloadFile(<local path ie. ~/Downloads/c.txt>)

Can't you use:

#codesnippet   
import webbrowser
webbrowser.open("URL")

Replace "URL" with the web address of the file stored on the internet server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM