安裝和使用Linux CURL

來源:互聯網
上載者:User

--獲得安裝包,從網上直接下載或者其他途徑,這裡直接wget

# wget http://curl.haxx.se/download/curl-7.17.1.tar.gz

--解壓到目前的目錄

# tar -zxf curl-7.17.1.tar.gz

--進入解壓後的目錄內

# cd curl-7.17.1

--配置,指定安裝的目錄,這裡是“/usr/local/curl”

# ./configure --prefix=/usr/local/curl

--

# make

--安裝

# make install

--安裝完畢

使用:

將curl命令加入環境變數,

命令列裡執行(僅對本會話起作用,或者在.bash_profile、.bashrc檔案裡配置環境變數):

# export PATH=$PATH:/usr/local/curl/bin

然後就可以使用了

# curl http://www.baidu.com

出來好多html代碼,是百度首頁的代碼

入門的使用說明:

http://www.javaeye.com/topic/648143

-------------------------------------------------------------------------------------------

使用執行個體(發送POST請求):

# curl -d @json http://www.google.com/loc/json

-d —— 是以POST形式發送請求

@json —— @是從檔案中讀取資料,json檔案中的內容為{"address_language":"zh_CN","cell_towers":[{"cell_id":"36526","location_area_code":"14556","mobile_contry_code":"460","mobile_network_code":"02"}],"host":"maps.google.com","location":null,"request_address":true,"version":"1.1.0","wifi_towers":[]}

返回:

{"location":{"latitude":32.117302,"longitude":114.116598,"address":{"country":"中國","country_code":"CN","region":"河南省","city":"信陽市"},"accuracy":1625.0},"access_token":"2:FaXK0Xl_DHRbcQiK:5tGTJsZx1scpjUfJ"}

本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.