- 论坛徽章:
- 0
|
#!/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:
[url=ftp://[username[:password]@]hostname/filename]ftp://[username[:password]@]hostname/filename[/url]
If you want to use absolute paths to the file to download,
you should make the URL look something like this:
ftp://user:password@host/%2Fpath/to/myfile.txt
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)
将上面的命名为
ftp.py
比如放到c盘下
cmd-->cd ../.. >ftp.py
ftp://root:123456@192.168.1.2
a.txt
获取192.168.1.2主机上/root下面的a.txt,因为默认目录就是/root。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103983/showart_2085663.html |
|