curl下载安装与使用
下载:
https://curl.haxx.se/download.html
安装:
二进制安装。即解压即可。
使用
1、获取页面内容。
不加任何参数时,默认会发送GET请求来获取url内容到标准输出。
curl url
D:\AppCache\GolangHome\src\learn>curl www.apple.com
#===============================================================
D:\AppCache\GolangHome\src\learn>curl www.google.com
curl: () Empty reply from server
#===============================================================
D:\AppCache\GolangHome\src\learn>curl www.xiaomi.com
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title> Moved Permanently</title></head>
<body bgcolor="white">
<center><h1> Moved Permanently</h1></center>
<hr/>Powered by MiWeb</body>
</html>
#==============================================================
D:\AppCache\GolangHome\src\learn>curl www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstati
c.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true
src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f
value=> <input type=hidden name=rsv_bp value=> <input type=hidden name=rsv_idx value=> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength= autocomplete=off autofo
cus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com n
ame=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <
noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/log
in.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=b
ri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a
href=http://www.baidu.com/duty/>使用百度前必读</a> <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a> 京ICP证030173号 <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
#===================================================================
D:\AppCache\GolangHome\src\learn>
分别测试了苹果、谷歌、小米、百度。发现获得的页面内容大小相差较大。苹果啥也不给,霸道。谷歌则给了一句温馨提示语。小米则简洁地回应了一个html,重定向了。百度则回应一堆信息。
2、获取http响应的头部信息。
D:\AppCache\GolangHome\src\learn>curl -I http://www.apple.com
HTTP/1.1 Moved Permanently
Server: GHost
Content-Length:
Location: https://www.apple.com/
Cache-Control: max-age=
Expires: Sun, Sep :: GMT
Date: Sun, Sep :: GMT
Connection: keep-alive
strict-transport-security: max-age=
Set-Cookie: geo=CN; path=/; domain=.apple.com
Set-Cookie: ccl=shCgHjtuYBarTIycW/rvIg==; path=/; domain=.apple.com #===================================================================
D:\AppCache\GolangHome\src\learn>curl -I http://www.google.com
curl: () Empty reply from server
#====================================================================
D:\AppCache\GolangHome\src\learn>curl -I http://www.xiaomi.com
HTTP/1.1 Moved Permanently
Server: nginx
Date: Sun, Sep :: GMT
Content-Type: text/html
Content-Length:
Connection: close
Location: https://www.mi.com #===================================================================
D:\AppCache\GolangHome\src\learn>curl -I http://www.baidu.com
HTTP/1.1 OK
Server: bfe/1.0.8.18
Date: Sun, Sep :: GMT
Content-Type: text/html
Content-Length:
Last-Modified: Mon, Jun :: GMT
Connection: Keep-Alive
ETag: "575e1f6f-115"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Accept-Ranges: bytes #==========================================================================
D:\AppCache\GolangHome\src\learn>
这次谷歌给的响应头依然是一句简短的提示语,太节约资源了。其他三个则普通给出响应头,其中苹果和小米都重定向了。
4、同时给出http的响应头和响应体。
D:\AppCache\GolangHome\src\learn>curl -i http://www.google.com
curl: () Empty reply from server
#===============================================================
D:\AppCache\GolangHome\src\learn>curl -i http://www.apple.com
HTTP/1.1 Moved Permanently
Server: GHost
Content-Length:
Location: https://www.apple.com/
Cache-Control: max-age=
Expires: Sun, Sep :: GMT
Date: Sun, Sep :: GMT
Connection: keep-alive
strict-transport-security: max-age=
Set-Cookie: geo=CN; path=/; domain=.apple.com
Set-Cookie: ccl=Pnj18CxjBB4h7LQaKIIkxg==; path=/; domain=.apple.com #=====================================================================
D:\AppCache\GolangHome\src\learn>curl -i http://www.xiaomi.com
HTTP/1.1 Moved Permanently
Server: nginx
Date: Sun, Sep :: GMT
Content-Type: text/html
Content-Length:
Connection: close
Location: https://www.mi.com <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title> Moved Permanently</title></head>
<body bgcolor="white">
<center><h1> Moved Permanently</h1></center>
<hr/>Powered by MiWeb</body>
</html>
#=============================================================
D:\AppCache\GolangHome\src\learn>curl -i http://www.baidu.com
HTTP/1.1 OK
Server: bfe/1.0.8.18
Date: Sun, Sep :: GMT
Content-Type: text/html
Content-Length:
Last-Modified: Mon, Jan :: GMT
Connection: Keep-Alive
ETag: "588604ec-94d"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Set-Cookie: BDORZ=; max-age=; domain=.baidu.com; path=/
Accept-Ranges: bytes <!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstati
c.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true
src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f
value=> <input type=hidden name=rsv_bp value=> <input type=hidden name=rsv_idx value=> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength= autocomplete=off autofo
cus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com n
ame=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <
noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/log
in.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=b
ri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a
href=http://www.baidu.com/duty/>使用百度前必读</a> <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a> 京ICP证030173号 <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
#====================================================
D:\AppCache\GolangHome\src\learn>
谷歌依旧发挥着极简风格,就一句话。苹果给头不给体。小米则都给。百度则臃肿不堪。
curl下载安装与使用的更多相关文章
- curl下载安装
curl下载地址 https://curl.haxx.se/download.html 选择windows generic 下的 下载安装 安装完后解压配置系统环境变量 CURL_HOME ...
- 学了C语言,如何利用CURL写一个下载程序?—用nmake编译CURL并安装
在这一系列的前一篇文章学了C语言,如何为下载狂人写一个磁盘剩余容量监控程序?中,我们为下载狂人写了一个程序来监视磁盘的剩余容量,防止下载的东西撑爆了硬盘.可是,这两天,他又抱怨他的下载程序不好用,让我 ...
- centos shell编程5 LANMP一键安装脚本 lamp sed lnmp 变量和字符串比较不能用-eq cat > /usr/local/apache2/htdocs/index.php <<EOF重定向 shell的变量和函数命名不能有横杠 平台可以用arch命令,获取是i686还是x86_64 curl 下载 第三十九节课
centos shell编程5 LANMP一键安装脚本 lamp sed lnmp 变量和字符串比较不能用-eq cat > /usr/local/apache2/htdocs/ind ...
- Linux使用curl 方式安装docker-compose 后执行docker-compose version 检查安装是否成功时出错的解决办法
0x0.缘起: 今天在一台新的Fedora 25上按照官方文档,使用curl方式安装 docker-compose后,验证是否安装成功时出错: 安装时使用的命令为; curl -L https://g ...
- MongoDB简介以及下载安装
什么是MongoDB ? MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统.运行稳定,性能高 在高负载的情况下,添加更多的节点,可以保证服务器性能. MongoDB 旨在 ...
- windows下curl的安装和简单使用
curl是利用URL语法在命令行方式下工作的开源文件传输工具.它支持很多协议:FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE 以及 LDAP. 一 ...
- Linux CURL的安装
Linux CURL的安装 Linux CURL的安装 --获得安装包,从网上直接下载或者其他途径,这里直接wget# wget http://curl.haxx.se/download/cur ...
- curl的安装与使用
linux 下的curl扩展安装,记录一下(发现网上好多抄袭的也不检测一下能不能用) 1.下载curl安装包: https://curl.haxx.se/download.html 2.解压: 如 t ...
- MongoDB下载+安装+运行
一. 官网下载安装 MongoDB 提供了 OSX 平台上 64 位的安装包,你可以在官网下载安装包. 下载地址:MongoDB官网-Community Server 选择适合自己平台的版本, 下载对 ...
随机推荐
- UMP系统架构 Zookeeper
- 关于Synthesis
1,当追求面积最小时 会以牺牲Fmax为代价,可以使用一下setting: fit_pack_for_density=on fit_report_lab_usage_stats=on 可在 .qsf ...
- 廖雪峰Java13网络编程-1Socket编程-5UDP编程
1. UDP编程: 不需要建立连接 可以直接发送和接收数据 1.1 客户端 DatagramSocket sock = new DatagramSocket(){} sock.connect(addr ...
- RabbitMQ代码操作之发消息和序列化机制
几个自动配置类: 1.RabbitAutoConfiguration2.有自动配置了连接工厂 ConnectionFactory3.RabbitProperties 封装了RabbitMQ的配置4.R ...
- CentOS7使用firewalld打开关闭防火墙与端口(转)
CentOS7使用firewalld打开关闭防火墙与端口 1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop ...
- Joomla - 后台系统(功能简介)
Joomla - 后台系统简介 全局配置
- 04_Spring AOP两种代理方法
什么是AOP? AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是O ...
- 03_Spring Bean的装配模式_基于Annotation配置方式
前言 在Spring中尽管使用XML配置文件可以实现Bean的装配工作,但如果应用中Bean的数量较多,会导致XML配置文件过于臃肿,从而给维护和升级带来一定的困难.从JDK 5开始提供了名为Anno ...
- RaspberryPi(一)
[1]格式化TF卡 // 注意格式 [2]烧录系统 // 烧录完成后不要点弹出的击格式化选项 [3]查找IP.修改静态IP(保持和台式机或笔记本同网段) arp -a //物理地址以B8开头 //或者 ...
- kafka一些问题点的分析
kakfka架构图: 理解kafka需要理解三个问题. 1.producer,broker,consumer,ZK的工作模式. broker,ZK是作为一个后台服务,而producer和consume ...