Linux命令(77)之curl

linux命令之curl

1.curl介绍

linux命令之curl是一款强大的http命令行工具,它支持文件的上传和下载,是综合传输工具。

2.curl用法

curl [参数] [url]

curl参数
参数说明
-C断点续传
-o <filename>把输出写到filename文件中
-x在给定的端口上使用HTTP代理
-显示当前的传送状态
-i打印服务器回应的HTTP头
-I向服务器发出 HEAD 请求,然会将服务器返回的 HTTP 标头打印出来;等价于--head

3.实例

3.1.下载CentOS-Base.repo到/etc/yum.repos.d/

命令:

curl -C - -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

[root@rhel77 ~]# curl -C - -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0   3731      0 --:--:-- --:--:-- --:--:--  3726
[root@rhel77 yum.repos.d]# cd /etc/yum.repos.d/
[root@rhel77 yum.repos.d]# ls -l CentOS-Base.repo 
-rw-r--r-- 1 root root 2523 Aug 28 15:07 CentOS-Base.repo
[root@rhel77 yum.repos.d]# 

3.2.使用指定端口,进行代理设置

命令:

curl -x 39.156.66.18:80 www.baidu.com
 

[root@rhel77 yum.repos.d]# curl -x 39.156.66.18:80 www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.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=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></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 name=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&amp;tpl=mn&amp;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/login.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=bri 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>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
[root@rhel77 yum.repos.d]# 

3.3.打印服务器回应的HTTP头

命令:

curl -i www.baidu.com

[root@rhel77 ~]# 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: 2381
Content-Type: text/html
Date: Mon, 28 Aug 2023 07:16:06 GMT
Etag: "588604c8-94d"
Last-Modified: Mon, 23 Jan 2017 13:27:36 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.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=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></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 name=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&amp;tpl=mn&amp;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/login.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=bri 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>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
[root@rhel77 ~]# 

3.4.向服务器发出 HEAD 请求,然会将服务器返回的 HTTP 标头打印出来

命令:

curl -I www.baidu.com       -I:大小字母i

curl --head www.baidu.com

[root@rhel77 ~]# 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: Mon, 28 Aug 2023 07:17:14 GMT
Etag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18[root@rhel77 ~]# curl --head 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: Mon, 28 Aug 2023 07:17:18 GMT
Etag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18[root@rhel77 ~]# 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/75157.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Web server failed to start. Port 8080 was already in use.之解决方法

问题&#xff1a; Web server failed to start. Port 8080 was already in use&#xff0c;这句错误描述意思是当前程序的端口号8080被占用了&#xff0c;需要将占用该端口的程序停止掉才行&#xff1b;错误如图所示&#xff1a; 解决方法&#xff1a; 按住winr&#xff0c;输入…

React 消息文本循环展示

需求 页面上有个小喇叭&#xff0c;循环展示消息内容 逻辑思路 设置定时器&#xff0c;修改translateX属性来实现滚动&#xff0c;判断滚动位置&#xff0c;修改list位置来实现无限滚动 实现效果 代码 /** Author: Do not edit* Date: 2023-09-07 11:11:45* LastEditors: …

android studio的Android Drawable Preview

Android Drawable Preview 应用后&#xff0c;如下图&#xff1a; 再也不用一个一个点开去看了 其他学习资料&#xff1a; 1、付费专栏《Android kotlin入门到进阶系列讲解》&#xff1a;https://blog.csdn.net/qq_35091074/category_11036895.html 2、免费专栏《Android kot…

【大虾送书第九期】速学Linux:系统应用从入门到精通

目录 &#x1f36d;写在前面 &#x1f36d;为什么学习Linux系统 &#x1f36d;Linux系统的应用领域 &#x1f36c;&#xff11;.Linux在服务器的应用 &#x1f36c;&#xff12;.嵌入式Linux的应用 &#x1f36c;&#xff13;.桌面Linux的应用 &#x1f36d;Linux的版本选择 &a…

使用PHPStudy在本地快速建立网站并实现局域网外访问(无公网IP)

文章目录 使用工具1. 本地搭建web网站1.1 下载phpstudy后解压并安装1.2 打开默认站点&#xff0c;测试1.3 下载静态演示站点1.4 打开站点根目录1.5 复制演示站点到站网根目录1.6 在浏览器中&#xff0c;查看演示效果。 2. 将本地web网站发布到公网2.1 安装cpolar内网穿透2.2 映…

高教社杯数模竞赛特辑论文篇-2018年B题:智能 RGV 的动态调度策略(附获奖论文及MATLBA和JAVA代码)(代码篇2)

本文代码较多,分为多篇来写,其他篇详见 智能 RGV 的动态调度策略(附获奖论文及MATLBA代码) 智能 RGV 的动态调度策略(附获奖论文及MATLBA和JAVA代码)(代码篇1)

无涯教程-JavaScript - IMPOWER函数

描述 IMPOWER函数以x yi或x yj文本格式返回加到幂的复数。求幂的复数的计算方法如下- $$(x yi)^ n r ^ ne ^ {n \theta} r ^ n \cos n \theta ir ^ n sin n \theta $$ 哪里- $$r \sqrt {x ^ 2 y ^ 2} \:\:和\:\:\theta \tan ^ {-1} \left(\frac {y} {x} \right)\:…

数字 IC 设计职位经典笔/面试题(四)

共100道经典笔试、面试题目&#xff08;文末可全领&#xff09; 画出 CMOS 电路的晶体管级电路图,实现 YA*BC(DE).&#xff1f; 画出 YABC 的 CMOS 电路图&#xff0c;画出 YABCD 的 CMOS 电路图。 利用与非门和或非门实现 YABC(DE)((AB’)(CD)’(CE)’)’ 三个两输入与非门&a…

【力扣每日一题】2023.9.10 课程表Ⅱ

目录 题目&#xff1a; 示例&#xff1a; 分析&#xff1a; 代码&#xff1a; 题目&#xff1a; 示例&#xff1a; 分析&#xff1a; 今天的题目和昨天类似&#xff0c;不过今天要我们求出学习所有课程的先后顺序。 昨天只需要我们求出能否学习完所有课程&#xff0c;因此…

Himall商城-公共方法

目录 1 Himall商城-公共方法 1.1 /// 修改快递信息 1.2 /// 所有订单是否都支付 1.2.1 //有待付款的订单,则未支付完成 Himall商城-公共方法 #region 公共方法 public static List<InvoiceTitleInfo> GetInvoiceTitles(long userid) {

JAVASE事件监听

代码&#xff1a; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner;import javax.swing.JButton; import javax.…

CSS文字居中对齐学习

CSS使用text-align属性设置文字对齐方式&#xff1b;text-align:center&#xff0c;这样就设置了文字居中对齐&#xff1b; <!DOCTYPE html> <html><head><meta charset"UTF-8"><title>css 水平居中</title><style>.box …

ICCV 2023 | SuS-X:仅靠类别名称微调CLIP模型,剑桥大学联合DeepMind出品

论文链接&#xff1a; https://arxiv.org/abs/2211.16198 代码仓库&#xff1a; https://github.com/vishaal27/SuS-X 对比语言图像预训练&#xff08;Contrastive Language-Image Pre-training&#xff0c;CLIP&#xff09; 已成为计算机视觉社区通向自然语言领域的一种常用的…

机器学习入门教学——交叉验证

1、简介 交叉验证是在机器学习建立模型和验证模型参数时常用的办法&#xff0c;一般被用于评估一个机器学习模型的表现。更多的情况下&#xff0c;我们也用交叉验证来进行模型选择。【注】在训练模型时&#xff0c;为了提高模型的质量&#xff0c;我们会将数据集划分为训练集、…

代码随想录Day_60打卡

①、柱状图中最大的矩形 给定 n 个非负整数&#xff0c;用来表示柱状图中各个柱子的高度。每个柱子彼此相邻&#xff0c;且宽度为 1 。 求在该柱状图中&#xff0c;能够勾勒出来的矩形的最大面积。 事例&#xff1a; 输入&#xff1a;heights [2,1,5,6,2,3] 输出&#xff1a;1…

spring框架技术学习

spring入门 <!--老韩解读1. 配置monster对象/javabean2. 在beans中可以配置多个bean3. bean表示就是一个java对象4. class属性是用于指定类的全路径->spring底层使用反射创建5. id属性表示该java对象在spring容器中的id, 通过id可以获取到对象6. <property name"…

UDP聊天室

1.头文件 /* * 文件名称&#xff1a;UDP.h * 创 建 者&#xff1a;crx * 创建日期&#xff1a;2023年09月3日 * 描 述&#xff1a; */ #ifndef _UDP_H #define _UDP_H#include <stdio.h> #include <sys/types.h> /* See NOTES */ #includ…

使用Redis控制表单重复提交控制接口访问频率

场景一&#xff1a;控制表单重复提交 防重提交有很多方案&#xff0c;从前端的按钮置灰&#xff0c;到后端synchronize锁、Lock锁、借助Redis语法实现简单锁、RedisLua分布式锁、Redisson分布式锁&#xff0c;再到DB的悲观锁、乐观锁、借助表唯一索引等等都可以实现防重提交&am…

Unity 之 Material (材质)渲染3D对象的重要组件

文章目录 介绍一些代码例子 介绍 在Unity中&#xff0c;Material&#xff08;材质&#xff09;是一种用于渲染3D对象的重要组件。Material定义了对象的外观&#xff0c;包括其颜色、纹理、光照属性和反射等。以下是关于Material的详细介绍&#xff1a; 创建Material&#xff1…

云计算时代的采集利器

大家好&#xff01;在今天的知识分享中&#xff0c;我们将探讨一个在云计算环境中的爬虫应用利器——独享IP。如果你是一名爬虫程序员&#xff0c;或者对数据采集和网络爬虫有浓厚的兴趣&#xff0c;那么这篇文章将向你展示独享IP在云计算环境下的应用价值。 1. 什么是独享IP&…