home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / source code / Demo / tkinter / www / www1.py < prev    next >
Encoding:
Python Source  |  1995-12-17  |  338 b   |  20 lines  |  [TEXT/R*ch]

  1. #! /usr/local/bin/python
  2.  
  3. # www1.py -- print the contents of a URL on stdout
  4.  
  5. import sys
  6. import urllib
  7.  
  8. def main():
  9.     if len(sys.argv) != 2 or sys.argv[1][:1] == '-':
  10.         print "Usage:", sys.argv[0], "url"
  11.         sys.exit(2)
  12.     url = sys.argv[1]
  13.     fp = urllib.urlopen(url)
  14.     while 1:
  15.         line = fp.readline()
  16.         if not line: break
  17.         print line,
  18.  
  19. main()
  20.