--获得安装包,从网上直接下载或者其他途径,这里直接wget
# wget http://curl./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./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"} |
|