Python POST request
Previous/
Next Article 10:29:15/person type: Python
View (176 )/
Comment (0 )/
Score (0/
0)
Post Method 1:
The request data format is:
<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
<Bosscustomervo>
<Userid> test </userid>
<Applicationid> SME-MEETING </applicationid>
<Billingmode> 006317 </billingmode>
<Email> user@163.com </Email>
<Pattitle> etester </pattitle>
<Description> memo </description>
</Bosscustomervo>
Remove <? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?> You can directly use Python post to send data.
Import urllib2
Cookies = urllib2.httpcookieprocessor ()
Opener = urllib2.build _ opener (cookies)
Xml_request = ''' <bosscustomervo> <userid> 99 tdfdf </userid> <applicationid> SME-MEETING </applicationid> \
<Email> email_yrdydfasdfsadfsad@163.com </Email> <paytitle> temporary flood attacks </paytitle> \
<Description> memo </description> </bosscustomervo> '''
Request = urllib2.request (
Url = 'HTTP: // 192.168.1.1: 1111/stomer ',
Headers = {'content-type': 'application/xml', 'charset': 'utf-8 '},
Data = xml_request)
F = opener. Open (request)
Print F. Read ()
Another Post Implementation Method
# POST request other methods
Import urllib2, urllib
Data = {'name': 'www ', 'Password': '000000 '}
F = urllib2.urlopen (
Url = 'HTTP: // www.ideawu.net /',
Data = urllib. urlencode (data)
)
Print F. Read ()