Tutorial :send xml file to http using python



Question:

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


Solution:1

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.


Solution:2

You can achieve that through a standard http post request.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »