-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathga_spider.py
More file actions
executable file
·30 lines (24 loc) · 912 Bytes
/
Copy pathga_spider.py
File metadata and controls
executable file
·30 lines (24 loc) · 912 Bytes
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
28
29
30
import threading, Queue, urllib, datetime, os, sys
def download(jobs):
while True:
url, name=jobs.get()
#with report:
print "Downloading ... %s\n" % name,
if not os.path.isfile(name) or os.path.getsize(name) < 1024:
urllib.urlretrieve(url, name)
jobs.task_done()
def main():
jobs = Queue.Queue()
for i in range(10):
t = threading.Thread(target=download, args=(jobs))
t.daemon = True
t.start()
d = datetime.date(1978, 6, 19)
while d < datetime.date.today():
jobs.put(("http://images.ucomics.com/comics/ga/%s/ga%s.gif"\
%(d.strftime("%Y"), d.strftime("%y%m%d")), \
"ga%s.gif" % d.strftime("%y%m%d")))
d = d + datetime.timedelta(days = 1)
jobs.join()
if __name__ == "__main__":
main()