Python uses post to submit data
This article mainly introduces python's method of submitting data through post, which involves Python's skills in using post to transmit data. For more information, see
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 |
#-*-Coding: cp936 -*-
Import urllib2
Import urllib
Def postHttp (name = None, tel = None, address = None,
Price = None, num = None, paytype = None,
Posttype = None, other = None ):
Url = "http://www.xxx.com/dog.php"
# Define the data to be submitted
Postdata = dict (name = name, tel = tel, address = address, price = price,
Num = num, paytype = paytype, posttype = posttype, other = other)
# Url Encoding
Postdata = urllib. urlencode (postdata)
# Enable cookie
Request = urllib2.Request (url, postdata)
Response = urllib2.urlopen (request)
Print response
|
Call the function:
The Code is as follows:
PostHttp ('name', 'telephony ', 'address', '000000', '1', 'cash on delivery', 'EMS domestic postal express delivery ', 'hunger and ears rabbit-International brands ')
I hope this article will help you with Python programming.