开发者

send xml file to http using python

开发者 https://www.devze.com 2023-01-03 15:21 出处:网络
how can i send an xml file on my system to an http server using python standard library?开发者_运维百科?import urllib

how can i send an xml file on my system to an http server using python standard library?开发者_运维百科?


import urllib

URL = "http://host.domain.tld/resource"
XML = "<xml />"

parameter = urllib.urlencode({'XML': XML})

a) using HTTP POST

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

b) using HTTP GET

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

That would be the simplest solution.


You can achieve that through a standard http post request.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号