[mod_python] httplib questions

Michael S. Fischer michael at dynamine.net
Sun Apr 25 12:25:15 EST 2004


Your question isn't really about mod_python; rather, it's about making the
best use of the httplib module.  
 
You might want to use urllib.urlopen() or urllib.urlretrieve() instead.  The
latter class will follow redirections transparently.  
 
If you must use httplib, you'll need to parse the response yourself, and
then make a subsequent connection to the target URL specified in the
redirection response.
 
Read the relevant HTTP-related RFCs (http://www.faqs.org/rfcs/) if you'd
like to understand the inner workings of the HTTP protocol.
 
--Michael
 


  _____  

From: mod_python-bounces at modpython.org
[mailto:mod_python-bounces at modpython.org] On Behalf Of Doug Gray
Sent: Sunday, April 25, 2004 11:45 AM
To: mod_python at modpython.org
Subject: [mod_python] httplib questions



Im trying to capture information from a site that I need to log into first
but Im having problems making it work.

 

Python 2.3.3

 

 

Im using the following example as my start

 

Import httplib,urllib

params = urllib.urlencode({'username': 'test', 'password': 'test')

headers = {"Content-type": "application/x-www-form-urlencoded","Accept":
"text/plain"}

conn = httplib.HTTPConnection("fantasygames.sportingnews.com")

conn.request("POST", "/crs/home_check_reg.html", params, headers)

response = conn.getresponse()

return response.status

 

 

the status that is returned is 302 which I think is something to do with
redirect.

 

Questions.

1.     How do I handle 302s??

2.     can sites block you from capture data in which you are a member of
that site.

3.     Is there a good forum for Python so I can do a detailed search on the
topic of capturing web source from websites.

 

 

Thanks

Doug

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.modpython.org/pipermail/mod_python/attachments/20040425/9f86a56e/attachment-0001.html


More information about the Mod_python mailing list