New User - Using tutorial and Docs - POST returns 302 Found

JohnV loftmaster at
Tue Mar 3 02:02:10 CET 2009

I got it!  You can see the code at the bottom of this post.  Sorry for
three posts on this question.

I have to run the program one time just to get the dynamically
generated redirect URL for the POST (it looks like this)
The document has moved <a href="

I then paste the redirected URL ("
htmlos/001863.1.059070780420726458) into the script and run it again
and it works.

My question now is how do I bypass this manual step and grab the
redirect URL automatically without human intervention.  In other
words, how do I get the python script to find out what the redirect
URL is going to be (it is dynamic and times out after 50 minutes if
idle) and automatically update the script with the redirect URL?

Also, I was able to figured out how to open a file and send the data
so almost all my work is done, excect for this pesky URL redirect on
the POST.

f = open('C:\Users\Owner\Desktop\mydata.txt', 'r')
read_data =


import httplib, urllib
params = urllib.urlencode({'textarea1': read_data})
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
conn = httplib.HTTPConnection("")
conn.request("POST", "/pages/htmlos/001863.5.083914970120726458",
params, headers)
response = conn.getresponse()
print response.status, response.reason
data =

f = open('C:\Users\Owner\Desktop\pydata.txt', 'a')

More information about the Python-list mailing list