Python POST login test, pythonpost Login

Source: Internet
Author: User
Tags pycharm community edition

Python POST login test, pythonpost Login

Without explanation, go directly to the Code:

1 #! /Usr/bin/env python 2 #-*-encoding: UTF-8-*-3 4 "5 @ version: v1.0 6 @ author: elijahxb 7 @ OS: linux 8 @ contact: elijahxb@163.com 9 @ site: http://www.cnblogs.com/elijahxb 10 @ software: PyCharm Community Edition 11 @ file: zhangye. py 12 @ time: 17-7-2 "14 15 ''' 16 This login test: 17 USERNAME: test00000000118 PASSWORD: test00119 URL: http://www.zhangye.ccoo.cn/20 TYPE: POST21 HOST: www. zhangye. ccoo. cn22 POSTURL: http://www.zhangye.ccoo.cn/login9.asp23 POSTDATA: username = test000000001 & password = test00124 ''' 25 import httplib26 import urllib27 28 HOST = '2017. 92.232.234 '29 SOURCEURL = "http://www.zhangye.ccoo.cn/" 30 POSTURL = 'HTTP: // www.zhangye.ccoo.cn/login9.asp'31 PORT = 8032 STRICT = False # default False, indicating that the status row returned by the server cannot be resolved, whether to throw a BadStatusLine exception 33 TIMEOUT = 534 HEADERS = {35 'content-type': 'application/x-www-form-urlencoded', 36 "Accept ": "*/*" 37} 38 TestDATA = {39 'username': 'test001 _ 001', 40 'Password': 'test001' 41} 42 TestDATA = urllib. urlencode (TestDATA) 43 44 try: 45 # Conn = httplib. HTTPConnection (HOST, PORT, STRICT, TIMEOUT, SOURCEURL) 46 HttpClient = httplib. HTTPConnection (HOST) 47 HttpClient. request ('post', POSTURL, TestDATA, HEADERS) 48 49 response = HttpClient. getresponse () 50 print response. status51 print response. reason52 print response. read () 53 print response. getheaders () 54 failed t Exception, e: 55 print e56 finally: 57 if HttpClient: 58 HttpClient. close ()

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.