By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,585 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,585 IT Pros & Developers. It's quick & easy.

Https Form Page

P: n/a
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,formatter

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

data='Name=x&Adress=x'
headers = {"Content-type":
"application/x-www-form-urlencoded","Accept": "text/plain"}

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

response = http.getresponse()
print response.status, response.reason

http.send(data)

code,msg,headers = http.getreply()

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

HTML=http.getfile().read()
MyParser=htmllib.HTMLParser(formatter.NullFormatte r())
MyParser.feed(HTML)
# Print all the anchors from the results page
print MyParser.anchorlist
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hasan D <py*******@gmail.com> wrote:

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,formatter

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


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

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

Or, even better, the HTTPSConnection class.

http://www.noah.org/python/https/
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.