-2

Below is the curl command and wanted to use in python by using request. I am beginner to python. Appreciate advice/help.

curl --header 'Content-Type: text/xml;charset=UTF-8' --data-binary @c:/abcd.xml -X POST http://www.dneonline.com/calculator.asmx

B PM
  • 1

2 Answers2

1

You can use Requests to POST data:

import requests

url = 'http://www.dneonline.com/calculator.asmx'
files = {'c': open('/abcd.xml', 'rb')}
r = requests.post(url, files=files)

Requests is now a defacto standard.

Laurent LAPORTE
  • 21,958
  • 6
  • 58
  • 103
0

Either use requests module or call it from a shell. So,

from subprocess import call
call("curl --header 'Content-Type: text/xml;charset=UTF-8' --data-binary @c:/abcd.xml -X POST",shell=True) 
Milan Velebit
  • 1,933
  • 2
  • 15
  • 32