Re: Https Form Page
Hasan D [EMAIL PROTECTED] 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, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Https Form Page
It all really, really, really depends on your script processing the form. My suggestion is to use the openssl s_client program, manually submit your data, and see what your server is responding with. -jag inline: Pasted Graphic.tiffJoshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 9, 2005, at 12:04 AM, Hasan D wrote: I cant figure out, always gives me the form page. Everything looks ok but ? On Apr 9, 2005 2:07 AM, Joshua Ginsberg [EMAIL PROTECTED] wrote: If url is your formpage and your formdata is correct, it should work. Do you need to have a cookie set? Is it 304 redirecting you? -jag Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 4:51 PM, Hasan D wrote: Thank you for fast reply. Your program works fine. But when i print the https_response it gives me the form page. I want to send the form and print the result page. On Apr 9, 2005 12:19 AM, Joshua Ginsberg [EMAIL PROTECTED] wrote: Try: import urllib2, urllib formdata = urllib.urlencode({'a':1,'b':2}) request = urllib2.Request(url) request.add_data(formdata) opener = urllib2.build_opener(urllib2.HTTPSHandler()) urllib2.install_opener(opener) fs = urllib2.urlopen(request) https_response = fs.read() https_headers = fs.info().headers https_mimetype = fs.info().type -jag Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 2:13 PM, Hasan D 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) data='Name=xAdress=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=7b=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.NullFormatter()) MyParser.feed(HTML) # Print all the anchors from the results page print MyParser.anchorlist -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Https Form Page
I cant figure out, always gives me the form page. Everything looks ok but ? On Apr 9, 2005 2:07 AM, Joshua Ginsberg [EMAIL PROTECTED] wrote: If url is your formpage and your formdata is correct, it should work. Do you need to have a cookie set? Is it 304 redirecting you? -jag Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 4:51 PM, Hasan D wrote: Thank you for fast reply. Your program works fine. But when i print the https_response it gives me the form page. I want to send the form and print the result page. On Apr 9, 2005 12:19 AM, Joshua Ginsberg [EMAIL PROTECTED] wrote: Try: import urllib2, urllib formdata = urllib.urlencode({'a':1,'b':2}) request = urllib2.Request(url) request.add_data(formdata) opener = urllib2.build_opener(urllib2.HTTPSHandler()) urllib2.install_opener(opener) fs = urllib2.urlopen(request) https_response = fs.read() https_headers = fs.info().headers https_mimetype = fs.info().type -jag Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 2:13 PM, Hasan D 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) data='Name=xAdress=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=7b=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.NullFormatter()) MyParser.feed(HTML) # Print all the anchors from the results page print MyParser.anchorlist -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
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,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=xAdress=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=7b=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.NullFormatter()) MyParser.feed(HTML) # Print all the anchors from the results page print MyParser.anchorlist -- http://mail.python.org/mailman/listinfo/python-list
Re: Https Form Page
Try: import urllib2, urllib formdata = urllib.urlencode({'a':1,'b':2}) request = urllib2.Request(url) request.add_data(formdata) opener = urllib2.build_opener(urllib2.HTTPSHandler()) urllib2.install_opener(opener) fs = urllib2.urlopen(request) https_response = fs.read() https_headers = fs.info().headers https_mimetype = fs.info().type -jag inline: Pasted Graphic.tiffJoshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 2:13 PM, Hasan D 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) data='Name=xAdress=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=7b=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.NullFormatter()) MyParser.feed(HTML) # Print all the anchors from the results page print MyParser.anchorlist -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list