通過python post提交數據的代碼演示
# -- 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"
#定義要提交的數據 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
</pre>
本文由用戶 byyc 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!