Skip to content

Commit 5e3acfd

Browse files
committed
Script for grabbing pics from 40th dinner
1 parent b1f4463 commit 5e3acfd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

picgrabber/picgrabber.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import urllib2
2+
import urllib
3+
import string
4+
import os
5+
6+
url = "http://www.deegan.id.au/temp/20140918-ucc-40th/"
7+
pics = []
8+
folder = "pics"
9+
10+
try:
11+
f = urllib2.urlopen(url)
12+
for line in f:
13+
if "<img src=" in line:
14+
pics.append(string.split(string.split(line, "Thumbnail ", 1)[1], " ", 1)[0])
15+
except urllib2.URLError, e:
16+
print(e)
17+
exit(0)
18+
19+
if not os.path.exists(folder):
20+
os.mkdir(folder)
21+
22+
for pic in pics:
23+
print(pic)
24+
if not os.path.exists(folder + "/" + pic):
25+
urllib.urlretrieve(url + pic, folder + "/" + pic)
26+
print(folder + "/" + pic + " - Download Complete")
27+
else:
28+
print(folder + "/" + pic + " - Already Exists")
29+
30+
print pics
31+

0 commit comments

Comments
 (0)