urllib2的post使用
#-*- coding: utf-8 -*-import urllibimport urllib2import timedef post(url, data): req = urllib2.Request(url) data = urllib.urlencode(data) #enable cookie opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) response = opener.open(req, data) return response.codedef main(): posturl = "http://dianzhang.dev.haalee.com/admin/login" data = {'username':'admin','form_password':'1122312'} print post(posturl, data) if __name__ == '__main__': while 1: main() time.sleep(60)