Find the most recent file on a http server (python)
Question: I have a site: <http://planet.osm.ch/replication/hour/000/006/> and I need to
get the most recent file listed on the server. How can I accomplish this
through python 2.6.x and using only the standard library.

Thank you

Edit:

When I mean the most recent, I mean the most recent files listed by the date
field.


Answer: Many people prefer to use Beautiful Soup for these tasks. But since you want
to use only the standard library , here is a quick solution using the re and
urllib2 modules.

    
    
    import urllib2
    import re
    page = urllib2.urlopen(Your_site).read()
    print re.findall(r"<a.+>(\d+.+)</a>",page)[-1]
    

Note : I know it is bad practice to use re to parse HTML, but this is a simple
website and the question requires so.

