> Sorry, I think you didn't get my later post -- than in fact was from a > month ago... > Seehttp://article.gmane.org/gmane.comp.python.general/613312/ > urllib2 should handle a 302 redirect automatically. > > -- > Gabriel Genellina
I went to the link you provided and sure enough there was your post. However, the date was all wrong. I did not even submit to this list until March 2,2009 so the date on your other post was probably in European format 03/02/2009 but read as US 02/03/2009. In any case, thank you. The code does get my request to the page however the data sent in the POST does not arrive with the request. <code> import httplib, urllib, urllib2 f = open(r'C:\Users\Owner\Desktop\mydata.txt', 'r') read_data = f.read() f.close() params = urllib.urlencode({'textarea1': read_data}) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} url = "http://www.thenational.us:80/pages/start/test/getpost.html" req = urllib2.Request(url, params, headers) response = urllib2.urlopen(req) data = response.read() response.close() print data f = open(r'C:\Users\Owner\Desktop\pydata.txt', 'a') f.write(data) f.close() </code> I even changed the params line to to: params = urllib.urlencode({'textarea1': 'somedata'}) then I tried taking part of the header out ("Accept": "text/plain") like this: headers = {"Content-type": "application/x-www-form-urlencoded"} I still get to the getpost.html page because response has the html from that page, but textarea1 does not get passed. Putting :80 or leaving it out of the URL does not seem to matter either way I get to the getpost page, just no data is passed. I am running Python 2.5 r25:51908 MSC v.1318 32 bit (Intel) on wind32 and after doing a search on Python Post problems, I read that urllib2 handled 302 redirect POST incorrectly at least in 2.5x . See http://bugs.python.org/issue1401 Maybe my code is still lacking some command, or I need to install a newer version of Python. That option (installing) seems a little daunting to me as I have no experience but I can learn if that will fix the problem for me. Thanks for the help so far, any furhter suggestions appreciated. -- http://mail.python.org/mailman/listinfo/python-list