当前位置: 技术问答>linux和unix
请问wget是否能把相对路径转换成绝对路径
来源: 互联网 发布时间:2016-10-06
本文导语: 用wget下载某些页面,但是离线浏览后,如果链接是相对路径,就不能给导到网站上去,造成无法访问,所以想问问有什么办法可以让wget把所有连接都转换成绝对路径,查了半天手册也没有找到,知找到了--convert-...
用wget下载某些页面,但是离线浏览后,如果链接是相对路径,就不能给导到网站上去,造成无法访问,所以想问问有什么办法可以让wget把所有连接都转换成绝对路径,查了半天手册也没有找到,知找到了--convert-link可以把绝对路径转换回相对路径。
|
不知道你的file的内容格式, 不过wget -k option是可以将相对路径转换成绝对路径的
可以试试
可以试试
cat file | xargs -r -n1 wget -k
|
事实
-k
--convert-links
After the download is complete, convert the links in the document
to make them suitable for local viewing. This affects not only the
visible hyperlinks, but any part of the document that links to
external content, such as embedded images, links to style sheets,
hyperlinks to non-HTML content, etc.
Each link will be changed in one of the two ways:
* The links to files that have been downloaded by Wget will be
changed to refer to the file they point to as a relative link.
Example: if the downloaded file /foo/doc.html links to
/bar/img.gif, also downloaded, then the link in doc.html will
be modified to point to ../bar/img.gif. This kind of transfor-
mation works reliably for arbitrary combinations of directo-
ries.
* The links to files that have not been downloaded by Wget will
be changed to include host name and absolute path of the loca-
tion they point to.
Example: if the downloaded file /foo/doc.html links to
/bar/img.gif (or to ../bar/img.gif), then the link in doc.html
will be modified to point to http://hostname/bar/img.gif.
-k
--convert-links
After the download is complete, convert the links in the document
to make them suitable for local viewing. This affects not only the
visible hyperlinks, but any part of the document that links to
external content, such as embedded images, links to style sheets,
hyperlinks to non-HTML content, etc.
Each link will be changed in one of the two ways:
* The links to files that have been downloaded by Wget will be
changed to refer to the file they point to as a relative link.
Example: if the downloaded file /foo/doc.html links to
/bar/img.gif, also downloaded, then the link in doc.html will
be modified to point to ../bar/img.gif. This kind of transfor-
mation works reliably for arbitrary combinations of directo-
ries.
* The links to files that have not been downloaded by Wget will
be changed to include host name and absolute path of the loca-
tion they point to.
Example: if the downloaded file /foo/doc.html links to
/bar/img.gif (or to ../bar/img.gif), then the link in doc.html
will be modified to point to http://hostname/bar/img.gif.
|
在下载完的时候, 把下载下来的网页修改一个, 在首行或者末行加上
分析网页时, 所有的相对路径就有参考路径了.
|
既然手册都看了, 那就不可以
|
既然手册里都没提到 应该是不可用的了
|
不可用。先用其它命令转换,在wget如何?
|
帮忙顶下了,不太了解
|
没用过,俺下东西全在图形界面操作的……
|
对wget不是很了解,一点愚见:
网站存放网页有一定的路径。
在用wget下载的时候,仿照网站上的绝对路径构造一个下载相对路径是不是就可以解决。
网站存放网页有一定的路径。
在用wget下载的时候,仿照网站上的绝对路径构造一个下载相对路径是不是就可以解决。