tags:

views:

54

answers:

3

Hi,

I want to start writing python to support some of my web applications. Mainly i'm trying to fetch pages, send POST data to urls and some string manipulation.

I understand that there are some disadvantages with the urllib in the new versions.

Can anyone please tell me which release is best for my needs?

Thanks

+2  A: 

Step 1. Use urllib2 to fetch pages. Save them in flat files

http://docs.python.org/library/urllib2.html

Step 2. Use a WSGI-based server like werkzeug to serve those pages.

http://docs.python.org/library/wsgiref.html

http://werkzeug.pocoo.org/

When you get that working, plug it into a proper web server (like Apache) with mod_wsgi.

http://code.google.com/p/modwsgi/

S.Lott
Should I apply all the above when using the latest Python version? or one of the older ones?
John Darman
@John Daman: **Update** your question to include asking which version of Python.
S.Lott
+2  A: 

I don't know your needs ... but did you try twill. It can fetch pages, fill forms, and whatever you need. It contains a "scripting languages" and can be embedded in your python application.

http://twill.idyll.org/

ohe
A: 

Since there's nothing about your needs that seem to require a specific python version, or a package only available to 2 or 3, I'd use whatever you're most comfortable with, or already runs on your server. It sounds like you're new to python, and don't plan on using it for much, but want a nearly copy-and-paste solution to your problem. Since there's still more information around built up from years of people having posting solutions to problems on their blogs about using python 2, I'd use the newest version of that. Obviously if something is already installed on your server, no need to go mucking with other versions if you just want a few utility scripts. Additionally, porting is still easier to do from 2 to 3 than the reverse; esp. for a small codebase, shouldn't be hard to switch if you ever find the need.

Thomas