Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send xml file to http using python

Tags:

python

http

xml

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

like image 507
Arnab Sen Gupta Avatar asked Jun 11 '10 07:06

Arnab Sen Gupta


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 simplest solution.

like image 168
zovision Avatar answered Sep 20 '22 06:09

zovision


You can achieve that through a standard http post request.

like image 29
k_b Avatar answered Sep 23 '22 06:09

k_b