日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

WGET and CURL

發(fā)布時間:2023/12/18 编程问答 33 如意码农
生活随笔 收集整理的這篇文章主要介紹了 WGET and CURL 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

目錄

  • WGET and CURL
    • 對比
    • wget
    • curl
      • curl使用示例

WGET and CURL

對比

CURL 和WGET都可以用來下載文件,用法也類似:curl/wget [-option...] [url..]
但兩者還是有區(qū)別的
|對比||
|--|--|
|curl| 1. curl是LInux下的數(shù)據(jù)傳輸工具,可以通過URL想服務(wù)器上傳數(shù)據(jù),或者從服務(wù)器下載數(shù)據(jù)。curl支持HTTP、FTP、SMTP、RSTP等應(yīng)用層協(xié)議。 2. curl參數(shù)更多更復(fù)雜,需要依賴libcurl庫,可以把 cURL 想象成一個精簡的命令行網(wǎng)頁瀏覽器。它支持幾乎你能想到的所有協(xié)議,可以交互訪問幾乎所有在線內(nèi)容。唯一和瀏覽器不同的是,cURL 不會渲染接收到的相應(yīng)信息
|wget |wget是Linux系統(tǒng)中的文件下載命令, 支持HTTP、FTP等協(xié)議。 wget是非交互性的,且具有自動下載功能, 能自己在后臺工作。 也就是說在用戶logout之后,wget仍然能夠繼續(xù)完成自己的工作。 wget更簡單,不依賴其他的庫,且沒有那么多的復(fù)雜參數(shù)|

wget

參數(shù) 解釋
-d: 調(diào)試模式 -d參數(shù)能夠打印出wget運行時的調(diào)試信息:如HTTP報文頭等。這個參數(shù)非常有用。
-O: 指定本地文件名 wget www.sina.com -O sina.html表示將www.sina.com 的內(nèi)容下載到sina.html。
-b: 后臺運行 wget運行在后臺,用戶logout之后仍能繼續(xù)下載

curl

參數(shù) 用法 詳解
-o 傳輸?shù)街付ㄎ募簿褪且付ㄎ募?/td> eg:curl -o baidu_index.html www.baidu.com可以將百度首頁的html源碼保存到baidu_index.html文件中
-O 使用url默認(rèn)文件名傳輸 eg:curl -O http://img.wallpapersking.com/800/2012-8/20120812103710.jpg 直接將圖片保存到本地文件20120812103710.jpg
-A --user-agent 設(shè)置用戶代理發(fā)送給服務(wù)器
-b --cookie <name=string/file> cookie字符串或文件讀取位置
-c小寫c --cookie-jar 操作結(jié)束后把cookie寫入到這個文件中
-C大寫C --continue-at 斷點續(xù)轉(zhuǎn)
-D --dump-header 把header信息寫入到該文件中
-e --referer 來源網(wǎng)址
-f --fail 連接失敗時不顯示http錯誤
-o --output 把輸出寫到該文件中
-O --remote-name 把輸出寫到該文件中,保留遠程文件的文件名
-r --range 檢索來自HTTP/1.1或FTP服務(wù)器字節(jié)范圍
-s --silent 靜音模式。不輸出任何東西
-T --upload-file 上傳文件
-u --user <user[:password]> 設(shè)置服務(wù)器的用戶和密碼
-w --write-out [format] 什么輸出完成后
-x --proxy <host[:port]> 在給定的端口上使用HTTP代理
-# --progress-bar 進度條顯示當(dāng)前的傳送狀態(tài)

curl使用示例

下載docker compose包到指定文件
curl -L https://github.com/docker/compose/releases/download/1.24.0-rc1/docker-compose-Linux-x86_64> /usr/local/bin/docker-compose
|用法|命令|解釋|
|--|--|--|
|下載頁面: |curl -o index.html http://url.com |
|下載文件并顯示簡單進度條:|curl -# -o centos6.8.iso http://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-minimal.iso |
|斷點續(xù)傳: |curl -# -o centos6.8.iso -C - http://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-minimal.iso |
|偽造來源頁面: |curl -e http://url.com http://B.com | #告訴B目標(biāo)網(wǎng)站,我是從地址url來的
|偽造代理設(shè)備: |curl -url " Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" http://B.com | 告訴B目標(biāo)網(wǎng)站,我是GOOGLE爬蟲蜘蛛" Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"當(dāng)然其實換成"Mozilla/5.0 AppleWebKit/600 Mobile MicroMessenger/6.0"就是微信內(nèi)置瀏覽器
|查看本站的http頭: |curl -I http://url.com |輸出內(nèi)容一般為:HTTP/1.1 200 OK;Date: Fri, 25 Nov 2016 16:45:49 GMT;Server: Apache;Set-Cookie: rox__Session=abdrt8vesprhnpc3f63p1df7j4; path=/;...
|設(shè)置http請求頭: |curl -H "Cache-Control:no-cache" http://url.com |
|發(fā)送表單數(shù)據(jù): |curl -F "pic=@logo.png" -F "site=aiezu" http://url.com/ |
|發(fā)送cookie: |curl -b "domain=url.com" http://url.com

curl退出碼

退出碼 錯誤描述
1 Unsupported protocol. This build of curl has no support for this protocol.
2 Failed to initialize.
3 URL malformed. The syntax was not correct.
5 Couldn't resolve proxy. The given proxy host could not be resolved.
6 Couldn't resolve host. The given remote host was not resolved.
7 Failed to connect to host.
8 FTP weird server reply. The server sent data curl couldn't parse.
9 FTP access denied. The server denied login or denied access to the particular resource or directory you wanted to reach. Most often you tried to change to a directory that doesn't exist on the server.
11 FTP weird PASS reply. Curl couldn't parse the reply sent to the PASS request.
13 FTP weird PASV reply, Curl couldn't parse the reply sent to the PASV request.
14 FTP weird 227 format. Curl couldn't parse the 227-line the server sent.
15 FTP can't get host. Couldn't resolve the host IP we got in the 227-line.
17 FTP couldn't set binary. Couldn't change transfer method to binary.
18 Partial file. Only a part of the file was transferred.
19 FTP couldn't download/access the given file, the RETR (or similar) command failed.
21 FTP quote error. A quote command returned error from the server.
22 HTTP page not retrieved. The requested url was not found or returned another error with the HTTP error code being 400 or above. This return code only appears if -f/--fail is used.
23 Write error. Curl couldn't write data to a local filesystem or similar.
25 FTP couldn't STOR file. The server denied the STOR operation, used for FTP uploading.
26 Read error. Various reading problems.
27 Out of memory. A memory allocation request failed.
28 Operation timeout. The specified time-out period was reached according to the conditions.
30 FTP PORT failed. The PORT command failed. Not all FTP servers support the PORT command, try doing a transfer using PASV instead!
31 FTP couldn't use REST. The REST command failed. This command is used for resumed FTP transfers.
33 HTTP range error. The range "command" didn't work.
34 HTTP post error. Internal post-request generation error.
35 SSL connect error. The SSL handshaking failed.
36 FTP bad download resume. Couldn't continue an earlier aborted download.
37 FILE couldn't read file. Failed to open the file. Permissions?
38 LDAP cannot bind. LDAP bind operation failed.
39 LDAP search failed.
41 Function not found. A required LDAP function was not found.
42 Aborted by callback. An application told curl to abort the operation.
43 Internal error. A function was called with a bad parameter.
45 Interface error. A specified outgoing interface could not be used.
47 Too many redirects. When following redirects, curl hit the maximum amount.
48 Unknown TELNET option specified.
49 Malformed telnet option.
51 The peer's SSL certificate or SSH MD5 fingerprint was not ok.
52 The server didn't reply anything, which here is considered an error.
53 SSL crypto engine not found.
54 Cannot set SSL crypto engine as default.
55 Failed sending network data.
56 Failure in receiving network data.
58 Problem with the local certificate.
59 Couldn't use specified SSL cipher.
60 Peer certificate cannot be authenticated with known CA certificates.
61 Unrecognized transfer encoding.
62 Invalid LDAP URL.
63 Maximum file size exceeded.
64 Requested FTP SSL level failed.
65 Sending the data requires a rewind that failed.
66 Failed to initialize SSL Engine.
67 The user name, password, or similar was not accepted and curl failed to log in.
68 File not found on TFTP server.
69 Permission problem on TFTP server.
70 Out of disk space on TFTP server.
71 Illegal TFTP operation.
72 Unknown TFTP transfer ID.
73 File already exists (TFTP).
74 No such user (TFTP).
75 Character conversion failed.
76 Character conversion functions required.
77 Problem with reading the SSL CA cert (path? access rights?).
78 The resource referenced in the URL does not exist.
79 An unspecified error occurred during the SSH session.
80 Failed to shut down the SSL connection.
82 Could not load CRL file, missing or wrong format (added in 7.19.0).
83 Issuer check failed (added in 7.19.0).
XX More error codes will appear here in future releases. The existing ones are meant to never change.

本博客為Swagger-Ranger的筆記分享,文中源碼地址: https://github.com/Swagger-Ranger
歡迎交流指正,如有侵權(quán)請聯(lián)系作者確認(rèn)刪除: liufei32@outlook.com

總結(jié)

以上是生活随笔為你收集整理的WGET and CURL的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。