Mercurial > repos > xuebing > sharplabtool
annotate tools/data_source/fetch.py @ 0:9071e359b9a3
Uploaded
author | xuebing |
---|---|
date | Fri, 09 Mar 2012 19:37:19 -0500 |
parents | |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 Script that just echos the command line. | |
5 """ | |
6 | |
7 import sys, os, urllib | |
8 | |
9 assert sys.version_info[:2] >= ( 2, 4 ) | |
10 | |
11 BUFFER = 1048576 | |
12 | |
13 url = sys.argv[1] | |
14 out_name = sys.argv[2] | |
15 | |
16 out = open(out_name, 'wt') | |
17 try: | |
18 page = urllib.urlopen(url) | |
19 while 1: | |
20 data = page.read(BUFFER) | |
21 if not data: | |
22 break | |
23 out.write(data) | |
24 except Exception, e: | |
25 print 'Error getting the data -> %s' % e | |
26 out.close() |