954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Opening HTTP sessions with Python

Hi,

I'm writing a client program that downloads data from an HTTP server via urllib, like so:

ufile = urllib.urlopen(urlstring)
text = ufile.read()
# Do stuff with text

Nice and simple. Unfortunately, the server only accepts requests with a session ID embedded inside - and I don't know how to open sessions using urllib. I've tried looking in the forums here and elsewhere online, and all I got was very generic info on cookies - nothing specific to Python, really.

Does anyone have experience doing this? Can you send me a link?EDIT:
I found out about cookielib; I'm seeing what I can do with it now. Will let you know if I get it working. Still open to hints!

G-Do
Junior Poster
147 posts since Jun 2005
Reputation Points: 41
Solved Threads: 31
 

Have you done your required reading on sockets yet?
Here is one article ...
http://www.devshed.com/c/a/Python/Sockets-in-Python/

Also look at the two websites that come up when you run
help('urllib')

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

Thanks, Vegaseat. I'm reading the article now. I will post a solution if and when I get it.

G-Do
Junior Poster
147 posts since Jun 2005
Reputation Points: 41
Solved Threads: 31
 

Hmm. I figured it out, but the solution had little to do with Python, and more to do with the fact that one of the values I was passing in with the request wasn't in the format the servlet was expecting. :o Strange that I could make this work in Java, though.

G-Do
Junior Poster
147 posts since Jun 2005
Reputation Points: 41
Solved Threads: 31
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You