The examples in this article describe how Python submits data through post. Share to everyone for your reference. The implementation method is as follows:
#-*-coding:cp936-*-import urllib2import urllibdef posthttp (name=none,tel=none,address=none, price=None,num= None,paytype=none, posttype=none,other=none): url= "http://www.xxx.com/dog.php" #定义要提交的数据 Postdata=dict (Name=name,tel=tel,address=address,price=price, Num=num,paytype=paytype,posttype=posttype, Other=other) #url编码 postdata=urllib.urlencode (postdata) #enable cookie request = Urllib2. Request (Url,postdata) Response=urllib2.urlopen (Request) Print response
Call Function:
Copy the Code code as follows:
Posthttp (' name ', ' phone ', ' address ', ' 230 yuan ', ' 1 ', ' cod ', ' EMS domestic post speedpost ', ' Thirsty long eared Rabbit-International brand ')
Hopefully this article will help you with Python programming.