Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1688451
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类: Python/Ruby

2009-11-03 20:09:38

#!/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。
阅读(791) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~