加入收藏 | 设为首页 | 会员中心 | 我要投稿 佛山站长网 (https://www.0757zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

安装和使用Linux CURL

发布时间:2016-10-11 15:38:22 所属栏目:Linux 来源:网络整理
导读:--获得安装包,从网上直接下载或者其他途径,这里直接wget # wget http://curl.haxx.se/download/curl-7.17.1.tar.gz --解压到当前目录 # tar -zxf curl-7.17.1

--获得安装包,从网上直接下载或者其他途径,这里直接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.cn/OS/Linux/

(编辑:佛山站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读