【问题标题】:Curl To Pycurl TranslationCurl 到 Pycurl 的翻译
【发布时间】:2018-11-21 05:08:37
【问题描述】:

我一直在处理 curl 请求(来自 bash)

/usr/bin/curl -L -k -u admin:admin -X GET 'https://localhost/test/123/123'

如何将此请求转换为 pycurl 代码,并通过 python 实现,选项很重要,因为它是 REST API。

我在 curl 中使用的选项是

-k 表示不安全(ssl 绕过)

-L 重定向

-X 请求 GET

谢谢,

【问题讨论】:

    标签: pycurl


    【解决方案1】:

    您可以阅读documentation 以获取信息。它引用CURL's setopt options。如果您阅读文档,您会弄清楚您想知道什么,但我假设您在这里询问是因为您希望其他人为您阅读。

    import pycurl
    
    c = pycurl.Curl()
    c.setopt(c.URL, "https://localhost/test/123/123")
    c.setopt(c.SSL_VERIFYPEER, False) # -k
    c.setopt(c.FOLLOWLOCATION, True) # -L
    c.setopt(c.HTTPGET, True) # -X
    c.perform()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 2017-06-10
      相关资源
      最近更新 更多