#!/usr/bin/env python
"""
url retriever
Usage:
url_retrieve_urllib.py URL FILENAME
URL:
If the URL is an FTP URL the format should be:
If you want to use absolute paths to the file to download,
you should make the URL look something like this:
Notice the '%2F' at the beginning of the path to the file.
FILENAME:
absolute or relative path to the filename to save downloaded file as
"""
import urllib
import sys
if '-h' in sys.argv or '--help' in sys.argv:
print __doc__
sys.exit(1)
if not len(sys.argv) == 3:
print 'URL and FILENAME are mandatory'
print __doc__
sys.exit(1)
url = sys.argv[1]
filename = sys.argv[2]
urllib.urlretrieve(url, filename)
将上面的命名为
比如放到c盘下
cmd-->cd ../.. >ftp.py a.txt
获取192.168.1.2主机上/root下面的a.txt,因为默认目录就是/root。
阅读(826) | 评论(0) | 转发(0) |