wget下载整个网站的方法
转自: http://blog.itpub.net/29867/viewspace-716088/
(修改部分内容)
wget --restrict-file-name=ascii -m -c -nv -np -k -E -p http://www.w3school.com.cn/
wget --restrict-file-name=ascii -m -c -nv -np -k -E -p http://scrapy-chs.readthedocs.org
参数释义如下:
--restrict-file-name=ascii ,将文件名保存为ASCII格式。这样能避免utf-8文件名带来的麻烦(注:1.12版才支持ascii参数值)
-m 整站下载,mirror的缩写,是-N -r -l inf --no-remove-listing 这几个参数的快捷方式,具体详阅各自的说明
-c 续传
-nv 不显示详细的下载详情
-np don’t ascend to the parent directory.即下载的Web页面不越过后面指定的 http://www.xxx.com的范围。当然,如果你指定的是 http://www.xxx.com/aaa,则所有的web页面都要在 http://www.xxx.com/aaa下
-k 下载完成后,将页面文件中的链接转换为本地链接,便于离线浏览和制作chm等
-E 保存html/css文件时,使用合适的文件后缀。例如,在某些网站有些文件是服务器端动态生成的,虽然是css文件,但后缀并不是css,-E选项可以调整之
-p -np对页面文件做了限制,如果不加-p,则html所需的媒体文件也会受限于-np,-p则会下载html/css文件所需的所有媒体文件(图片、音频、视频等)
-R 拒绝下载的文件后缀列表,逗号分隔
至于下载到的文件的文件名变为了形如%A7这样百分号加16进制数字的形式,可以用个python程序来改变文件名:
————————————————————————————————————
import os, urllib, sys, getopt
class Renamer:
input_encoding = ""
output_encoding = ""
path = ""
is_url = False
def __init__(self, input, output, path, is_url):
self.input_encoding = input
self.output_encoding = output
self.path = path
self.is_url = is_url
def start(self):
self.rename_dir(self.path)
def rename(self, root, path):
try:
if self.is_url:
new = urllib.unquote(path).decode(self.input_encoding).encode(self.output_encoding)
else:
new = path.decode(self.input_encoding).encode(self.output_encoding)
os.rename(os.path.join(root, path), os.path.join(root, new))
except:
pass
def rename_dir(self, path):
for root, dirs, files in os.walk(path):
for f in files:
self.rename(root, f)
if dirs == []:
for f in files:
self.rename(root, f)
else:
for d in dirs:
self.rename_dir(os.path.join(root, d))
self.rename(root, d)
def usage():
print '''This program can change encode of files or directories.
Usage: rename.py [OPTION]...
Options:
-h, --help this document.
-i, --input-encoding=ENC set original encoding, default is UTF-8.
-o, --output-encoding=ENC set output encoding, default is GBK.
-p, --path=PATH choose the path which to process.
-u, --is-url whether as a URL
'''
def main(argv):
input_encoding = "utf-8"
output_encoding = "gbk"
path = ""
is_url = True
try:
opts, args = getopt.getopt(argv, "hi:o:p:u", ["help", "input-encoding=", "output-encoding=", "path=", "is-url"])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-i", "--input-encoding"):
input_encoding = arg
elif opt in ("-o", "--output-encoding"):
output_encoding = arg
elif opt in ("-p", "--path"):
path = arg
elif opt in ("-u", "--is-url"):
is_url = True
rn = Renamer(input_encoding, output_encoding, path, is_url)
rn.start()
if __name__ == '__main__':
main(sys.argv[1:])
————————————————————————————————————
rename.py -i utf-8 -o gbk -p <指定的下载目录> -u
文件改名方法来自于http://blog.csdn.net/kowity/article/details/6899256
wget下载整个网站的方法的更多相关文章
- linux下使用wget下载整个网站
linux下可以用wget下载整个网站,而且网站链接中包含utf-8编码的中文也能正确处理. 简要方法记录如下: wget --restrict-file-name=ascii -m -c -nv - ...
- wget下载整个网站
wget下载整个网站wget下载整个网站可以使用下面的命令 wget -r -p -k -np http://hi.baidu.com/phps , -r 表示递归下载,会下载所有的链接,不过要注意的 ...
- wget下载整个网站---比较实用--比如抓取Smarty的document
wget下载整个网站可以使用下面的命令 wget -r -p -k -np http://hi.baidu.com/phps, -r 表示递归下载,会下载所有的链接,不过要注意的是,不要单独使用这个参 ...
- 为什么wget只下载某些网站的index.html? wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com wget 下载整个网站,或者特定目录
wget -c -r -np -k -L -p http://blog.hesheyou.me -c, –continue 接着下载没下载完的文件 -r, –recursive 递归下载 -np, – ...
- wget下载整个网站或特定目录
下载整个网站或特定目录 wget -c -k -r -np -p http://www.yoursite.com/path -c, –continue 断点下载 -k, –convert-links ...
- wget 下载整个网站,或者特定目录
需要下载某个目录下面的所有文件.命令如下 wget -c -r -np -k -L -p www.xxx.org/pub/path/ 在下载时.有用到外部域名的图片或连接.如果需要同时下载就要用-H参 ...
- Centos下wget下载整个网站,或者目录全部文件
需要下载某个目录下面的所有文件.命令如下 wget -c -r -np -k -L -p www.xxx.org/pub/path/ 在下载时.有用到外部域名的图片或连接.如果需要同时下载就要用-H参 ...
- [转]wget 下载整个网站,或者特定目录
FROM : http://www.cnblogs.com/lidp/archive/2010/03/02/1696447.html 需要下载某个目录下面的所有文件.命令如下 wget -c -r - ...
- [No00006B]方便的网络下载工具wget 可下载网站目录下的所有文件(可下载整个网站)
wget是linux下命令行的下载工具,功能很强大,它能完成某些下载软件所不能做的,比如如果你想下载一个网页目录下的所有文件,如何做呢?网络用户有时候会遇到需要下载一批文件的情况,有时甚至需要把整个网 ...
随机推荐
- perl语言入门总结-第5章-输入输出
读取标准输入 chomp($line = <STDIN>); #去掉后面的换行 while (defined($line = <STDIN>)) { print "I ...
- 笔记-scrapy-extentions
笔记-scrapy-extentions 1. extentions 1.1. 开始 The extensions framework provides a mechanism for ...
- P1783 海滩防御
P1783 海滩防御 题目描述 WLP同学最近迷上了一款网络联机对战游戏(终于知道为毛JOHNKRAM每天刷洛谷效率那么低了),但是他却为了这个游戏很苦恼,因为他在海边的造船厂和仓库总是被敌方派人偷袭 ...
- 世界未解之谜之----------Android Gradle
今天运行项目,运行的debug出来的包竟然是命名过的,但是我的buildTypes里面的debug 并没有执行重命名操作.很奇怪,我的猜测是: 执行buildTypes的时候,虽然是assermdeb ...
- 剑指Offer - 九度1505 - 两个链表的第一个公共结点
剑指Offer - 九度1505 - 两个链表的第一个公共结点2013-11-24 20:09 题目描述: 输入两个链表,找出它们的第一个公共结点. 输入: 输入可能包含多个测试样例.对于每个测试案例 ...
- leetcode 【 Intersection of Two Linked Lists 】python 实现
题目: Write a program to find the node at which the intersection of two singly linked lists begins. Fo ...
- javascript将分,秒,毫秒转换为xx天xx小时xx秒(任何语言通用,最通俗易懂)
// 传入参数为总分钟数,如果为秒数,毫秒数,需要对 // 此处得到总秒数 注释部分的代码调整下. function toDateDMS(minutes){ // 将分钟转换为 天,时,分,秒 if( ...
- katalon系列一:初识Katalon Studio自动化测试工具
最近准备把公司的系统搞上UI自动化,先是自己用Python+selenium+pytest写了一个框架,开始写case的时候发现效率极其慢.原因为: (1)开发为提高前端响应时间,使用前端路由技术,一 ...
- 关于Ckpalyer播放器的MP4无法播放问题
此文是从网上摘要的 有时在本地使用ckplayer来播放视频,flv格式非常容易的就播放了,但是使用mp4格式却显示:加载失败.为什么呢? 首页看下你i的本地站点MIME类型中,是否增加 ...
- (笔记) RealTimeRender[实时渲染] C3
@author: 白袍小道 转载表明,查看随缘 前言: 从历史上看,图形加速始于每个像素扫描线上的插值颜色重叠一个三角形,然后显示这些值.包括访问图像数据允许纹理应用于表面.添加硬件 插入和测试z深度 ...