[Tutor] Getting web pages and formatting text

Kent Johnson kent37 at tds.net
Thu Aug 4 19:33:55 CEST 2005

David Holland wrote:
> I am trying to make a report I do easier (ie via a program not manually).
> Two questions :-
> 1)  Is it possible to download to your hard drive using python various 
> web pages ie if the pages have the structure
> http://address/node=xxx&pagretree=&fromdid=nx&objectid=ny 
> <http://address/node=xxx&pagretree=&fromdid=nx&objectid=ny>
> So you can download objectid=ny where ny=1,2,3,4 etc up to 20 for example

Sure, just use urllib.urlretrieve(), or, if you need to deal with things like proxies and authentication, urllib2.

> 2)  Is it possible to use python to put text into a table I don't mean 
> an sql table I mean a text table.

There is a nice recipe in the online Python Cookbook for formatting tabular data. Unfortunately I can't access the cookbook right now; try searching for 'table' at http://aspn.activestate.com/ASPN/Cookbook/Python


More information about the Tutor mailing list