send xml file to http using python

2019-06-17 15:47发布

how can i send an xml file on my system to an http server using python standard library??

标签: python xml http
2条回答
兄弟一词,经得起流年.
2楼-- · 2019-06-17 16:31

You can achieve that through a standard http post request.

查看更多
神经病院院长
3楼-- · 2019-06-17 16:44
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.

查看更多
登录 后发表回答