python使用requests發送text/xml報文數據


    def client_post_xmldata_requests(request_url,requestxmldata):
        #功能說明:發送請求報文到指定的地址並獲取請求響應報文
        #輸入參數說明:接收請求的URL,xml請求報文數據
        #輸出參數:請求響應報文
        #by xiaocc[20180709]        
        import requests

        head={"Content-Type":"text/xml; charset=UTF-8", 'Connection': 'close'} 
        print '客戶端請求xml報文數據為(客戶端 --> 服務端):\n',requestxmldata
        
        #客戶端發送請求報文到服務端
        r = requests.post(request_url,data=requestxmldata,headers=head)
        #客戶端獲取服務端的響應報文數據
        responsedata=r.text
        print '服務端的響應報文為(客戶端 <--服務端): ',responsedata
        print "get the status: ",r.status_code
                   
        #返回請求響應報文
        return responsedata

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM