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

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/data_source/fetch.py	Fri Mar 09 19:37:19 2012 -0500
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+"""
+Script that just echos the command line.
+"""
+
+import sys, os, urllib
+
+assert sys.version_info[:2] >= ( 2, 4 )
+
+BUFFER = 1048576
+
+url      = sys.argv[1]
+out_name = sys.argv[2]
+
+out = open(out_name, 'wt')
+try:
+    page = urllib.urlopen(url)
+    while 1:
+        data = page.read(BUFFER)
+        if not data:
+            break
+        out.write(data)
+except Exception, e:
+    print 'Error getting the data -> %s' % e
+out.close()