[Zope] Re. Scheduler product, anyone?

Jerry.Spicklemire@IFLYATA.COM Jerry.Spicklemire@IFLYATA.COM
Fri, 4 Feb 2000 14:16:06 -0500


I had to do this just yesterday, and the urllib.py module made it absolutely
painless. Here's the simplistic little script I came up with, whcih could be
called by cron, or some other task manager.

Later,
Jerry S.
---------------------------------------------------

"""
	urlgrabr.py is a simple script to hit an URL, 
	retreive the generated output, 
	and manipulate it, 
	e.g. save it as a file,
	
		python urlgrabr.py http://server/folder/object
file=filename.html
	
	based on parameters.
	
	Default is simply to request the URL, and exit, dumping all data.
"""

import urllib
import sys
import string

c_url	=  sys.argv[1]

c_action = None

u_url = urllib.urlopen(c_url)

if len(sys.argv) > 2	:
    
    	c_action = sys.argv[2]
    	
    	if string.lower(c_action[:5]) == "file="	:
    	
    		f_action = open(c_action[5:], "w")	#	file name
		for l in u_url.readlines()	:
			if string.strip(l[:-1])	:
				f_action.write(l)
		f_action.close()