How would I do this in Python 1 1
Mike Coleman
mkc+dated+1017286733.caec18 at mathdogs.com
Tue Feb 26 03:34:40 CST 2002
Bradley Miller <bradmiller at dslonramp.com> writes:
> Ok, I decided to follow the yellow brick road and now have a copy of Python
> 2.?? (something) on my NT box. I was trying a little example that
> requested a web page. That worked great. Now I have a little "hmm how
> would that work" project in mind . . . how would I get the last updated
> date/time from a web page? I know it's gotta be there somewhere, because
> Netscape will show it most of the time. I realize it's not going to be
> valid on dynamic pages, but that's not the purpose for my little experiment.
Here's a little script that does this (under Python 2):
#!/usr/bin/env python
import sys
import urllib
for u in sys.argv[1:]:
print urllib.urlopen(u).info().getheader('Last-Modified',
'error: no Last-Modified date')
It runs like so:
$ date.py http://www.mathdogs.com http://www.python.org
Tue, 18 Dec 2001 02:13:20 GMT
Sun, 17 Feb 2002 11:26:19 GMT
I think this will run in a console window in Windows, though I haven't tried
it.
Mike
More information about the Kclug
mailing list