Not explained, directly on the code:
1 #!/usr/bin/env python2 #-*-encoding:utf-8-*-3 4 """ 5 @version: v1.06 @author: Elijahxb7 @OS: Linux8 @contact: [email protected]9 @site: Http://www.cnblogs.com/elijahxbTen @software: pycharm Community Edition One @file: zhangye.py A @time: 17-7-2 pm 12:16 - """ - the " " - This login test: - username:test001_001 - password:test001 + url:http://www.zhangye.ccoo.cn/ - Type:post + HOST:www.zhangye.ccoo.cn A posturl:http://www.zhangye.ccoo.cn/login9.asp at postdata:username=test001_001&password=test001 - " " - ImportHttplib - ImportUrllib - -HOST ='182.92.232.234' insourceURL ="http://www.zhangye.ccoo.cn/" -PostURL ='http://www.zhangye.ccoo.cn/login9.asp' toPORT = 80 +STRICT = False#default False, indicating whether the Badstatusline exception is thrown when the state row returned by the server cannot be resolved -TIMEOUT = 5 theHEADERS = { * 'Content-type':'application/x-www-form-urlencoded', $ "Accept":"*/*"Panax Notoginseng } -TestDATA = { the 'username':'test001_001', + 'Password':'test001' A } theTestDATA =Urllib.urlencode (TestDATA) + - Try: $ #Conn = Httplib. Httpconnection (HOST, PORT, STRICT, TIMEOUT, sourceURL) $HttpClient =Httplib. Httpconnection (HOST) -Httpclient.request ('POST', PostURL, TestDATA, HEADERS) - theResponse =Httpclient.getresponse () - PrintResponse.StatusWuyi PrintResponse.reason the PrintResponse.read () - Printresponse.getheaders () Wu exceptException, E: - Printe About finally: $ ifHttpClient: -Httpclient.close ()
Python's post login test