zoukankan      html  css  js  c++  java
  • 用wget递归下载

    [备忘]:Linux命令行下常用的http下载工具有wget和curl。

    1. 这里用wget递归下载某目录下所有除html外的文件~

    wget -r -np --reject=html www.download.example

    其中:

    -r, 表示递归下载当前页面所有(子)链接

    -np,表示不去遍历父目录下内容

    --reject=html,不接受扩展名为html的文件

    或者可以把reject换做 --accept=iso,c,h,表示只接受以此结尾的文件,分隔符为逗号(comma-separated)

    2. 用curl来查看http过程

    curl -v here.is.your.url

    我用该选项查看取服务器上主页的过程,主要是这里包括了http header:

    zxluo@polaris:~$ curl -v 192.168.1.1
    * About to connect() to 192.168.1.1 port 80 (#0)
    *   Trying 192.168.1.1... connected
    * Connected to 192.168.1.1 (192.168.1.1) port 80 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
    > Host: 192.168.1.1
    > Accept: */*
    > 
    < HTTP/1.1 200 OK
    < Date: Tue, 26 Feb 2013 07:52:54 GMT
    < Server: Apache/2.2.16 (Debian)
    < Last-Modified: Wed, 18 Apr 2012 12:18:11 GMT
    < ETag: "a002-b1-4bdf30c7c06c0"
    < Accept-Ranges: bytes
    < Content-Length: 177
    < Vary: Accept-Encoding
    < Content-Type: text/html
    < 
    <html><body><h1>It works!</h1>
    <p>This is the default web page for this server.</p>
    <p>The web server software is running but no content has been added, yet.</p>
    </body></html>
    * Connection #0 to host 192.168.1.1 left intact
    * Closing connection #0

     另外,curl -i here.is.your.url只显示response的头信息。

    3. 表单提交

    发送表单信息有GET和POST两种方法。GET方法相对简单,只要把数据附在网址后面就行。

    curl example.com/form.cgi?data=xxx

      POST方法必须把数据和网址分开,curl就要用到--data参数。

    curl --data "data=xxx" example.com/form.cgi

      如果你的数据没有经过表单编码,还可以让curl为你编码,参数是--data-urlencode。

    curl --data-urlencode "date=April 1" example.com/form.cgi

     你可以用curl这样上传文件:

    curl --form upload=@localfilename --form press=OK [URL]

    4. HTTP认证

    有些网域需要HTTP认证,这时curl需要用到--user参数。

    curl --user name:password example.com

      

    参考资料:教你学用curl

    ——————
    无论在哪里做什么,只要坚持服务、创新、创造价值,其他的东西自然都会来的。
  • 相关阅读:
    第四次作业:个人项目-小学四则运算 “软件”之初版
    随笔 | 阅读《构建之法》1-5章感想
    随笔 | 分布式版本控制系统Git的安装与使用
    随笔 | 对软件工程的一些感想
    为什么加载 JavaScript 使用 "src",CSS 使用 "href"?有其含义还是历史语法遗留?
    webstrom 添加一键open in browser
    sublime 代码段
    二.sublime配置 sublimecondeintel 分号后不要提示
    一.sublime配置 sublime 新建文档 默认html
    chrome使用
  • 原文地址:https://www.cnblogs.com/pied/p/2883082.html
Copyright © 2011-2022 走看看