comparison tools/data_source/fetch.py @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:9071e359b9a3
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()