import urllib import urllib2 url = 'www.abc.com' form = {"name": '1234', "password": '4321'} data = urllib.urlencode(form) # 将字典以url形式编码 header = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)', # 浏览器头 'Referer': 'http://www.abc.com' # 反盗链 } request = urllib2.Request(url, data, header) response = urllib2.urlopen(request) print response.read()