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 选择适合自己平台的版本, 下载对 ...
随机推荐
- 简介、变量、常数、if、基础数据类型、注释、input()
### 1.python的历史 python2和python3的区别 python2 源码不统一,重复代码 python 源码统一,没有重复代码 2004 Django框架的诞生 2.python ...
- MATLAB 中自定义函数的使用
MATLAB在文件内部(在函数内部)定义函数,但文件名以开头函数来命名,与Java中每个文件只能有一个公开类,但在文件内部还是可以定义其他非公开类一个道理. 无参函数 do.m function do ...
- 在 U-BOOT 对 Nand Flash 的支持
1.1 U-BOOT 对从 Nand Flash 启动的支持 1.1.1 从 Nand Flash 启动 U-BOOT 的基本原理 1. 前 4K 的问题 如果 S3C2410 被配置成从 ...
- Luogu P2827 蚯蚓(模拟)
P2827 蚯蚓 题意 题目描述 本题中,我们将用符号\(\lfloor c\rfloor\)表示对\(c\)向下取整,例如:\(\lfloor 3.0\rfloor =\lfloor 3.1\rfl ...
- 内核下枚举进程 (二)ZwQuerySystemInformation
说明: SYSTEM_INFORMATION_CLASS 的5号功能枚举进程信息.其是这个函数对应着ring3下的 NtQuerySystemInformation,但msdn上说win8以后ZwQu ...
- DOM节点的创建、插入、删除
值得注意的是:节点的创建.插入以及删除都是操作父级容器.(1)创建var newDiv = documnet.createElement('div'); ——创建的元素只能操作一次 (2)插入/追加a ...
- Android开发 ViewPager删除Item后,不会更新数据和View
问题描述: 在使用ViewPager的适配器删除适配器里一个Item后依然会,而删除的这个item依然会保留缓存,适配器不会重新加载更新数据.如下代码: public class TReleaseCi ...
- nginx压力测试webbench
下载压力测试工具webbench wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz 安装依赖包 yum -y in ...
- Java 怎样实现调用其他方法
Java主类的main方法调用其他方法 方法1: funA()方法设为静态方法. 当主类加载到内存,funA()分配了入口地址,主要代码如下: public class test{ static vo ...
- ST(RMQ)算法(在线)求LCA
在此之前,我写过另一篇博客,是倍增(在线)求LCA.有兴趣的同学可以去看一看.概念以及各种暴力就不在这里说了,那篇博客已经有介绍了. 不会ST算法的同学点这里 ST(RMQ)算法在线求LCA 这个算法 ...