1、使用requests模块
import request
url=‘http://www.xxx.com/xxx‘
data={‘username‘:‘zhangsan‘,‘password‘:‘zhangsanpw‘}
r=requests.post(url,data=data)
print r.text2、使用urllib2模块
import urllib2
import urllib
url=‘http://www.xxx.com/xxx‘
data={‘username‘:‘zhangsan‘,‘password‘:‘zhangsanpw‘}
r = urllib2.Request(url,urllib.urlencode(data))
result = urllib2.urlopen(req)
print result.read()本文出自 “唐柏” 博客,请务必保留此出处http://4988084.blog.51cto.com/4978084/1891742
原文地址:http://4988084.blog.51cto.com/4978084/1891742