跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 这个命令用 requests 怎么写?
未分類
4 12 月 2020

这个命令用 requests 怎么写?

这个命令用 requests 怎么写?

資深大佬 : imn1 2

curl -X PROPFIND -u login -H “Content-Type: text/xml” -H “Depth: 1”
–data “<propfind xmlns=’DAV:’><prop><calendar-data xmlns=’urn:ietf:params:xml:ns:caldav’/></prop></propfind>”
https://myserver/joe/home/

谢了

大佬有話說 (8)

  • 資深大佬 : aonshuy

    https://curl.trillworks.com/

  • 主 資深大佬 : imn1

    @aonshuy
    这年头真是只有想不到的……

  • 資深大佬 : justin2018

    https://curl.trillworks.com/

    import requests

    headers = {
    ‘Content-Type’: ‘text/xml’,
    ‘Depth’: ‘1’,
    }

    data = {
    ‘<propfind xmlns’: ”DAV:’><prop><calendar-data xmlns=’urn:ietf:params:xml:ns:caldav’/></prop></propfind>’
    }

    response = requests.post(‘https://myserver/joe/home/’, headers=headers, data=data, auth=(‘login’, ”))

  • 資深大佬 : ysc3839

    @aonshuy @justin2018
    这个网站转出来似乎是错的,忽略了 PROPFIND method 。

  • 資深大佬 : no1xsyzy

    @ysc3839 去提个 issue 呗
    临时解决的话,应该还是用 requests.request(‘PROPFIND’, …)
    除此以外,直接 PyPI 上找找 WebDAV 库呗

  • 主 資深大佬 : imn1

    @no1xsyzy #5
    没搜到 py3 可用的 carddav,caldav 那个还好,只是它仅有 caldav,代码看得有点晕,想继成过来兼容 carddav 没搞定
    只是我需求没那么复杂,自用不需要理会各种 rfc 标准,分析出字段能读能写就行,requests + vobject 就够了

  • 資深大佬 : vone

    你命令里的 “-u login” 不知道为什么被 postman 忽略了,改为 “-u login:”,然后导入 postman,然后生成代码如下:

    import requests

    url = “https://myserver/joe/home/”

    payload=”<propfind xmlns=’DAV:’><prop><calendar-data xmlns=’urn:ietf:params:xml:ns:caldav’/></prop></propfind>”
    headers = {
    ‘Content-Type’: ‘text/xml’,
    ‘Depth’: ‘1’,
    ‘Authorization’: ‘Basic bG9naW46’
    }

    response = requests.request(“PROPFIND”, url, headers=headers, data=payload)

    print(response.text)

    postman 导入方式:主界面=> Import => Raw text => Continue 。

    https://i.loli.net/2020/12/06/5gvcKAYo1qEhrHR.jpg
    https://i.loli.net/2020/12/06/9m4abLBcCuysv1W.jpg

  • 資深大佬 : WordTian

    WEBDAV 是 HTTP 的协议扩展,requests 是 http 的库,理论上应该不支持的吧

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具