【问题标题】:send xml file to http using python使用python将xml文件发送到http
【发布时间】:2010-06-11 07:35:15
【问题描述】:

如何使用 python 标准库将我系统上的 xml 文件发送到 http 服务器??

【问题讨论】:

    标签: python xml http


    【解决方案1】:
    import urllib
    
    URL = "http://host.domain.tld/resource"
    XML = "<xml />"
    
    parameter = urllib.urlencode({'XML': XML})
    

    a) 使用 HTTP POST

    response = urllib.urlopen(URL, parameter)
    print response.read()
    

    b) 使用 HTTP GET

    response = urllib.urlopen(URL + "?%s" % parameter)
    print response.read()
    

    这将是最简单的解决方案。

    【讨论】:

      【解决方案2】:

      您可以通过标准的 http post 请求来实现。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-06-01
        • 1970-01-01
        • 2011-06-06
        • 1970-01-01
        • 2021-11-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多