You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
988 B

import requests
import json, xmljson
from lxml.etree import fromstring, tostring
import re
url="http://rates.kazpost.kz/postratesws/postratesws.wsdl"
#headers = {'content-type': 'application/soap+xml'}
headers = {'content-type': 'text/xml'}
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pos="http://webservices.kazpost.kz/postratesws">
<soapenv:Header/>
<soapenv:Body>
<pos:GetPostRateRequest>
<pos:MailInfo>
<pos:Product>7</pos:Product>
<pos:MailCat>2</pos:MailCat>
<pos:SendMethod>2</pos:SendMethod>
<pos:Weight>3500</pos:Weight>
<pos:From>13</pos:From>
<pos:To>3</pos:To>
<pos:SpecMarks/>
<pos:InCity/>
<pos:ExpressDlv/>
<pos:Size/>
<pos:DeclaredValue/>
</pos:MailInfo>
</pos:GetPostRateRequest>
</soapenv:Body>
</soapenv:Envelope>"""
response = requests.post(url,data=body,headers=headers)
print(response.text)
m = re.search(r'<ns2:PostRate>(\d+)</ns2:PostRate>', response.text)
print(m.group(1))