Https Form Page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hasan D

    #1

    Https Form Page

    I'm new on this httplib and urllib. Actually I dont know what should i use.

    I want to fill the form in a "https" page , and return the result . I
    write a test code but always gives errors. I cant find any good
    example about this on the net. What should I do about this ?


    import urlparse,urllib ,httplib,string ,htmllib,format ter

    #port="443"
    target="https://www.abc.com/"
    params = urllib.urlencod e({'spam': 1, 'eggs': 2, 'bacon': 0})
    http=httplib.HT TP("https://www.abc.com/",443)

    data='Name=x&Ad ress=x'
    headers = {"Content-type":
    "applicatio n/x-www-form-urlencoded","Ac cept": "text/plain"}

    print "Sending Data On "+target+"...\n "
    http.putrequest ("POST",target+ "/xxx.asp?q=7&b=1 1",params)

    response = http.getrespons e()
    print response.status , response.reason

    http.send(data)

    code,msg,header s = http.getreply()

    print "HTTP Code : ",str(code)
    print "HTTP Connection : ",msg
    print "HTTP headers : \n",headers,"\n "

    HTML=http.getfi le().read()
    MyParser=htmlli b.HTMLParser(fo rmatter.NullFor matter())
    MyParser.feed(H TML)
    # Print all the anchors from the results page
    print MyParser.anchor list
  • Tim Roberts

    #2
    Re: Https Form Page

    Hasan D <python.tr@gmai l.com> wrote:[color=blue]
    >
    >I'm new on this httplib and urllib. Actually I dont know what should i use.
    >
    >I want to fill the form in a "https" page , and return the result . I
    >write a test code but always gives errors. I cant find any good
    >example about this on the net. What should I do about this ?
    >
    >import urlparse,urllib ,httplib,string ,htmllib,format ter
    >
    >#port="443"
    >target="http s://www.abc.com/"
    >params = urllib.urlencod e({'spam': 1, 'eggs': 2, 'bacon': 0})
    >http=httplib.H TTP("https://www.abc.com/",443)[/color]

    If you want https, you should use the HTTPS class.

    http = httplib.HTTPS(" https://www.abc.com/",443)

    Or, even better, the HTTPSConnection class.

    M2Crypto will let you retrieve web pages from HTTPS servers. It's great, but it is short on documentation. I wrote these notes to help you get started.

    --
    - Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    Working...