hikyuu2/tools/importdata.py
2015-01-07 01:26:14 +08:00

36 lines
1.1 KiB
Python

#!/usr/bin/python
# -*- coding: utf8 -*-
# cp936
import urllib.request
import subprocess
import time
import sys
if __name__ == "__main__":
starttime = time.time()
net_filename = 'http://www.qianlong.com.cn/download/history/weight.rar'
if sys.platform == 'win32':
dest_filename = "c:\\stock\\weight\\weight.rar"
dest_dir = "c:\\stock\\weight"
subprocess.call(['del', dest_filename], shell=True)
else:
dest_filename = "/home/fasiondog/stock/weight/weight.rar"
dest_dir = "/home/fasiondog/stock/weight"
subprocess.call(['rm', dest_filename])
#subprocess.call(['rmdir', '/S', '/Q', "d:\\stock\\weight\\WEIGHT_sh"], shell=True)
#subprocess.call(['rmdir', '/S', '/Q', "d:\\stock\\weight\\WEIGHT_sz"], shell=True)
urllib.request.urlretrieve(net_filename, dest_filename)
subprocess.call(['unrar', 'x', '-o+', dest_filename, dest_dir])
subprocess.call(['importdata'])
endtime = time.time()
print("%.2fs" % (endtime-starttime))
print("%.2fm" % ((endtime-starttime)/60))