Linux curl使用簡單介紹(1)

來源:互聯網
上載者:User

Curl是Linux下一個很強大的http命令列工具,其功能十分強大。

1)讀取網頁

$ curl linuxidc.com">http://www.linuxidc.com

2)儲存網頁

$ curl http://www.linuxidc.com > page.html $ curl -o page.html http://www.linuxidc.com

3)使用的proxy伺服器及其連接埠:-x

$ curl -x 123.45.67.89:1080 -o page.html http://www.linuxidc.com

4)使用cookie來記錄session資訊

$ curl -x 123.45.67.89:1080 -o page.html -D cookie0001.txt http://www.linuxidc.com這個option: -D 是把http的response裡面的cookie資訊存到一個特別的檔案中去,這樣,當頁面被存到page.html的同時,cookie資訊也被存到了cookie0001.txt裡面了5)那麼,下一次訪問的時候,如何繼續使用上次留下的cookie資訊呢?

使用option來把上次的cookie資訊追加到http request裡面去:-b

$ curl -x 123.45.67.89:1080 -o page1.html -D cookie0002.txt -b cookie0001.txt http://www.linuxidc.com

6)瀏覽器資訊

$ curl -A "Mozilla/4.0 compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -o page.html -D cookie0001.txt http://www.linuxidc.com

7)referer

$ curl -A "Mozilla/4.0 compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -e "mail.linuxidc.com" -o page.html -D cookie0001.txt http://www.linuxidc.com這樣就可以騙對方的伺服器,你是從mail.linuxidc.com點擊某個連結過來的

8)下載檔案

$ curl -o 1.jpg http://cgi2.tky.3web.ne.jp/~zzh/screen1.JPG $ curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen1.JPG -O 可以按照伺服器上的檔案名稱,自動存在本地$ curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen[1-10].JPG

9)批量下載

$ curl -O http://cgi2.tky.3web.ne.jp/~{zzh,nick}/[001-201].JPG這樣產生的下載,就是~zzh/001.JPG ~zzh/002.JPG

……

~zzh/201.JPG ~nick/001.JPG ~nick/002.JPG

……

~nick/201.JPG


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.