Send xml file to http using python

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

+7
python xml
source share
2 answers
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 easiest solution.

+9
source

You can achieve this with a standard email request.

+1
source

All Articles