sh 使用WGET和CURL下载

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 使用WGET和CURL下载相关的知识,希望对你有一定的参考价值。

#! /bin/bash

wget -r -P /download/location -A jpg,jpeg,gif,png http://www.example.com

# see here for file types: http://www.gnu.org/software/wget/manual/wget.html#Types-of-Files
# -nd No Directories


# curl

curl -v # verbose (show what is being sent)
curl <website> # print content to console
curl -o <file> <website> # write content to file
curl -O <website>/file.zip # write content to file (same name) -> download
curl -I/--head <website> # get header information HEAD
curl -H/--header "X-Authorization: content" <website> # send header

# data (Content-Type: application/x-www-form-urlencoded), has to be url encoded!
# - default for webforms!
curl --data/-d "birthyear=1905&press=%20OK%20" <url> # POST request
curl -d "birthyear=1905" -d "press=%20OK%20" <url>
curl -d @file <url>
curl --data-binary "@path/to/file" # does not strip out newlines
curl --data-urlencode "name=I am Daniel" <website> # if data is not urlencoded yet

# form (Content-Type: multipart/form-data), with seperator and other MIME data
curl --form/-F upload=@localfilename --form $form-sb-name=$form-sb-value <website>

curl --upload-file uploadfile # PUT

curl -X GET <website> # arbitrary method

-i, --include # include received headers in output

以上是关于sh 使用WGET和CURL下载的主要内容,如果未能解决你的问题,请参考以下文章

sh curl - curl wget不验证证书进行https请求

纯 sh + telnet 中的 HTTP POST 文件:没有 curl,没有 wget

curl和wget的区别和用法介绍

curl和wget的区别和使用

curl和wget的区别和使用

curl和wget的区别和使用