栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

linux命令——curl常用命令使用方法简单了解

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

linux命令——curl常用命令使用方法简单了解

curl是什么?

全称CommandLine URL 或 CommandLine Uniform Resource Locator,在命令行方式下工作,利用URL的语法进行数据的传输或者文件的传输。是一个用来与服务器之间传输数据的工具。

功能:curl提供了一大堆非常有用的功能,包括代理访问、用户认证、ftp上传下载、HTTP POST、SSL连接、cookie支持、断点续传等。


以下是常用的curl命令:

1.curl url (发送get请求,返回该网址的html信息)
curl www.baidu.com

 百度一下,你就知道          
新闻 hao123 地图 视频 贴吧 更多产品

关于百度 about Baidu

©2017 Baidu 使用百度前必读  意见反馈 京ICP证030173号 

2.curl -i url(返回该网址的html信息+协议头部信息). 
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: keep-alive
Content-Length: 2381
Content-Type: text/html
Date: Wed, 16 Feb 2022 07:34:45 GMT
Etag: "588604d8-94d"
Last-Modified: Mon, 23 Jan 2017 13:27:52 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Set-cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/


 百度一下,你就知道          
新闻 hao123 地图 视频 贴吧 更多产品

关于百度 about Baidu

©2017 Baidu 使用百度前必读  意见反馈 京ICP证030173号 

3.curl -x proxy url(使用代理获取网页html信息)

这里我使用的代理可以访问google

curl -x http://10.10.8.66:1081 https://google.cn/webhp?source=g_cn

302 Moved
302 Moved
The document has moved
here.
4.curl -I url(仅返回请求头部信息)
 curl -I www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: keep-alive
Content-Length: 277
Content-Type: text/html
Date: Thu, 17 Feb 2022 06:02:56 GMT
Etag: "575e1f72-115"
Last-Modified: Mon, 13 Jun 2016 02:50:26 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
5.curl -v url(返回端口连接信息,http请求头部信息,网页html信息)

-v 参数表示显示一次 http 通信的整个过程,包括端口连接和 http request 头信息。

curl -v www.baidu.com
* Rebuilt URL to: www.baidu.com/
*   Trying 14.215.177.38...
* TCP_NODELAY set
* Connected to www.baidu.com (14.215.177.38) port 80 (#0)
> GET / HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: keep-alive
< Content-Length: 2381
< Content-Type: text/html
< Date: Fri, 18 Feb 2022 06:15:59 GMT
< Etag: "588604cf-94d"
< Last-Modified: Mon, 23 Jan 2017 13:27:43 GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
< 

 百度一下,你就知道          
新闻 hao123 地图 视频 贴吧 更多产品

关于百度 about Baidu

©2017 Baidu 使用百度前必读  意见反馈 京ICP证030173号 

* Connection #0 to host www.baidu.com left intact

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/741658.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号