通过wget实现静态页面的拷贝

作者: 老乔理查德 | 来源:发表于2016-05-14 16:17 被阅读417次

    需求

    我是看到tango with django的1.7版本经常国内访问不到,而自己又需要参考来编程,所以,自己先把网页拷贝下来,已备以后使用。

    如何做?

    由于tangowithdjango这本书都是静态页面
    可以通过wget的命令把别人的整个网页copy过来。而我自己本身有一个nginx的服务器跑着,所以只需要下载相应的网址到我的主机就是了。

    步骤

    1. 在(VPS/本机的)的终端中输入:
      [sudo] wget -r --no-parent http://www.tangowithdjango.com/book17/
      http://www.tangowithdjango.com/book17/ 是1.7版本的URI
      -r代表递归,所以就是说这个URI中的所有资源都需要wget下来;平时需要慎用此命令。
      --no-parent代表不要追溯到父目录
    2. 如果有VPS, 将文件夹的owner改为www-data(nginx), www(apache)
      另外记得把网址更改了。如果是mac中自用,则打开index即可以浏览

    log

    ~~ 在发起wget命令之后,VPS会自动递归获取http://www.tangowithdjango.com/book17/此文件夹中的文件。可以看到成功下载的文件的日志。
    <code>
    --2016-05-14 03:31:32-- http://www.tangowithdjango.com/book17/
    Resolving www.tangowithdjango.com (www.tangowithdjango.com)... 50.19.109.98
    Connecting to www.tangowithdjango.com (www.tangowithdjango.com)|50.19.109.98|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 44861 (44K) [text/html]
    Saving to: 'www.tangowithdjango.com/book17/index.html'

    100%[======================================>] 44,861 --.-K/s in 0.1s

    2016-05-14 03:31:32 (335 KB/s) - 'www.tangowithdjango.com/book17/index.html' saved [44861/44861]
    ……
    --2016-05-14 03:31:32-- http://www.tangowithdjango.com/book17/_static/pygments.css
    Reusing existing connection to www.tangowithdjango.com:80.
    HTTP request sent, awaiting response... 200 OK
    Length: 3932 (3.8K) [text/css]
    Saving to: 'www.tangowithdjango.com/book17/_static/pygments.css'

    100%[======================================>] 3,932 --.-K/s in 0s

    2016-05-14 03:31:32 (661 MB/s) - 'www.tangowithdjango.com/book17/_static/pygments.css' saved [3932/3932]
    ……

    </code>

    Reference

    http://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/wget.html
    https://www.quora.com/Where-can-I-download-Tango-with-Django
    http://www.tangowithdjango.com/book17/

    相关文章

      网友评论

        本文标题:通过wget实现静态页面的拷贝

        本文链接:https://www.haomeiwen.com/subject/lwomrttx.html