forked from migurski/PlanetIndex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
get-listing.py
27 lines (20 loc) · 799 Bytes
/
get-listing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from httplib import HTTPConnection
from time import strptime, mktime
from os.path import splitext
from urllib import urlopen
from re import findall
from os import utime, mkdir
base = 'http://planet.openstreetmap.org/'
html = urlopen(base).read()
for match in findall(r'<a href="(.+)">(.+)</a> +(\S.+\S) +(\S+)', html):
href, name, date, size = list(match)
if splitext(name)[1] in ('.bz2', '.md5', '.gz'):
time = mktime(strptime(date, '%d-%b-%Y %H:%M'))
print >> open(name, 'w'), 'Hello World.'
utime(name, (time, time))
#print name, date, time
elif name.endswith('/'):
time = mktime(strptime(date, '%d-%b-%Y %H:%M'))
mkdir(name)
utime(name, (time, time))
print name, date, time