关于curl:curl-d-data

-d, --data <data>POST办法提交数据时,须应用--data来指定申请数据。和浏览器填充好表单点击提交按钮雷同。在没有指定内容类型的状况下,应用表单编码间接应用--data提交数据时,中文会乱码。 curl --verbose -data "name=eliminate" --data "hobby=play 足球football" localhost:8080/userAdd当--data呈现屡次时,零碎会主动用符号&拼接起来。(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button.This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F, --form.-d, --data is the same as --data-ascii. To post data purely binary, you should instead use the --data-binary option. To URL-encode the value of a form field you may use --data-urlencode.If any of these options is used more than once on the same command line, the data pieces specified will be merged together with a separating &-symbol. Thus, using '-d name=daniel -d skill=lousy' would generate a post chunk that looks like 'name=daniel&skill=lousy'.If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. The contents of thefile must already be URL-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar.

August 31, 2023 · 1 min · jiezi

关于curl:curl-X-request-command

-X, --request <command>curl 默认的http申请办法是GET。通常状况下,你并不需要指定这个选项,他会通过其余命令推导进去。应用这个选项来指定http的申请办法,其实没卵用,他并不会扭转curl命令的理论行为,你指定了GET,它并不一定应用GET办法发送申请。今天上代码。 (HTTP) Specifies a custom request method to use when communicating with the HTTP server.The specified request will be used instead of the method otherwise used (which defaults to GET).Read the HTTP 1.1 specification for details and explanations. Common additional HTTP requests include PUT and DELETE, but related technologies like WebDAV offers PROPFIND, COPY, MOVE and more.Normally you don't need this option. All sorts of GET, HEAD, POST and PUT requests are rather invoked by using dedicated command line options.This option only changes the actual word used in the HTTP request, it does not alter the way curl behaves. So for example if you want to make a proper HEAD request, using -X HEAD will not suffice. You need to use the -I, --head option.(FTP) Specifies a custom FTP command to use instead of LIST when doing file lists with FTP.If this option is used several times, the last one will be used.

August 30, 2023 · 1 min · jiezi

关于curl:curl-i-include

-i, --includecurl www.baidu.com --include-i参数能够显示http response的头信息,连同网页代码一起。 (HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...

August 30, 2023 · 1 min · jiezi

关于curl:curl-o-output-file

-o, --output <file>惯例操作一:把一个申请的响应写入单个文件中curl www.baidu.com --output "baidu.txt"将会把百度首页的内容放入文件baidu.txt,baidu.txt在执行命令的当前目录生成。 惯例操作二:把多个申请的响应写入多个文件中(单个汇合变量)curl -v https://ai.baidu.com/ai-doc/FACE/{6k37c1nva,Yk37c1o30} --output "file_#1abc.txt"将会把两个接口https://ai.baidu.com/ai-doc/FACE/Okg7edktq,https://ai.baidu.com/ai-doc/FACE/6k37c1nva的内容别离存入file_Okg7edktqabc.txt,file_Yk37c1o30abc.txt文件中,大括号相当于汇合,外面的元素会替换掉指定的文件名中的#1字符。留神:此命令在linux下执行{}须要本义,即\{.....\} 惯例操作三:把多个申请的响应写入多个文件中(单个数组变量)curl https://ai.baidu.com/ai-doc/FACE/Yk37c1o3[0-5] --output "b_#1.txt"将会把六个接口: https://ai.baidu.com/ai-doc/FACE/Yk37c1o30https://ai.baidu.com/ai-doc/FACE/Yk37c1o32https://ai.baidu.com/ai-doc/FACE/Yk37c1o33https://ai.baidu.com/ai-doc/FACE/Yk37c1o34https://ai.baidu.com/ai-doc/FACE/Yk37c1o35https://ai.baidu.com/ai-doc/FACE/Yk37c1o36的响应别离存入以下文件 b_0.txtb_1.txtb_2.txtb_3.txtb_4.txtb_5.txt 惯例操作三:把多个申请的响应写入多个文件(多个汇合、多个数组变量)curl http://{site,host}.baidu.{one,two}.host[1-5].sina[0-5].com -o "#1_#2_#3_#4"请自行演示。 Write output to <file> instead of stdout.If you are using {} or [] to fetch multiple documents, you can use '#' followed by a number in the <file> specifier. Thatvariable will be replaced with the current string for the URL being fetched. Like in: curl http://{one,two}.site.com -o "file_#1.txt"or use several variables like: curl http://{site,host}.host[1-5].com -o "#1_#2"You may use this option as many times as the number of URLs you have.

August 30, 2023 · 1 min · jiezi

关于curl:curl-v-verbose

-v, --verbose以">"打头,示意申请头以"<"打头,示意响应头以"*"打头,示意curl命令提供的额定信息。 Makes the fetching more verbose/talkative. Mostly useful for debugging.A line starting with '>' means "header data" sent by curl, '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.Note that if you only want HTTP headers in the output, -i, --include might be the option you're looking for.If you think this option still doesn't give you enough details, consider using --trace or --trace-ascii instead.This option overrides previous uses of --trace-ascii or --trace.Use -s, --silent to make curl quiet.

August 30, 2023 · 1 min · jiezi

关于curl:curl-H-header-header

-H, --header <header>原生申请头curl -v -X POST localhost:8081/health 自定义申请头curl -v -X POST localhost:8081/health --header "X-Custom-Header;" --header "token:sneaky" --header "Host: baidu:8081" --header "User-Agent:"通过图片可察看到: 可重写curl命令自带的申请头。curl命令外部自带的申请头Host: localhost:8081被批改成了Host: baidu:8081。可移除curl命令自带的申请头。curl命令外部自带的申请头User-Agent: curl/8.0.1,被通过自定义申请头--header "User-Agent:"移除了。可自定义申请值为空的申请头。自定义申请头X-Custom-Header:是空值,通过设置申请头为:--header "X-Custom-Header;"。能够同时增加多个自定义申请头。 服务器后盾输入 (HTTP) Extra header to use when getting a web page.You may specify any number of extra headers. Note that if you should add a custom header that has the same name as one of the internal ones curl would use, your externally set header will be used instead of the internal one. This allows you to make even trickier stuff than curl would normally do.You should not replace internally set headers without knowing perfectly well what you're doing.Remove an internal header by giving a replacement without content on the right side of the colon, as in: -H "Host:". If you send the custom header with no-value then its header must be terminated with a semicolon, such as -H "X-Custom-Header;" to send "X-Custom-Header:".curl will make sure that each header you add/replace is sent with the proper end-of-line marker, you should thus not add that as a part of the header content: do not add newlines or carriage returns, they will only mess things up for you.See also the -A, --user-agent and -e, --referer options.This option can be used multiple times to add/replace/remove multiple headers.

August 30, 2023 · 1 min · jiezi

关于curl:后端请求数据计算量过大导致给用户的返回结果过于漫长一次调优的过程

【我的项目背景形容】 有一个表格,形容的是Snapshot-1和Snapshot-2之间的比照,数据比照的后果是由后端算进去的,前端只有负责渲染就能够。后端返回的数据实质是一个“森林”,每棵“树”都是三层,别离是:type/ class name/ object name。因为每棵树的计算量比拟大,孩子节点也比拟多,所以在前端渲染的时候,应用懒加载做了优化,即只有当用户开展某层的时候才会call到后端申请数据。所以,页面第一次渲染的时候,显示的是森林里所有树的第一层。除了页面的数据展现,Diff表格还反对csv download,因为csv须要拿到全量的比照数据,也就是整片森林,所以当用户点击CSV下载的时候,会先call后端拿到全量数据,再csv format,最初输入。 【呈现问题】有用户反馈说:CSV下载等了良久都在loading,问怎么回事? 【排查过程】1.前述环境 咱们有本地开发环境(对应本人本地的数据库,能够操作后端代码and前端代码)用户呈现问题的是prod环境(本地的前端是无奈call到prod环境的DB的)2.找到瓶颈 关上用户的报告,的确数据量很大,点击csv download,感觉下载一个diff文件,大略须要30s左右的工夫。也就是说代码逻辑没有问题,就是慢。关上控制台,看数据返回工夫。其实工夫不是很长,只有7s,因而,工夫的瓶颈不在这里。 接下来,就是看api callback外面的解决逻辑有什么能够优化的中央了。然而,如何拿到用户的数据呢?因为本地开发环境是没有方法连上prod的数据库的。【解决方案】:能够在开发者模式下,拿到api返回的数据,并将其保留成json,在前端代码里import进来进行解决。然而,因为返回的后果过于宏大,response无奈load,“复制粘贴”的打算失败。 【解决方案】:右击url,找到Copy as cURL,并在命令的结尾加上“>> 1.txt”,能够将response后果间接输入到文件,而不是命令行,不便复制。 万事俱备,开始查看瓶颈。在csv format中的每个函数前面,console.log一个工夫戳,便于查看到底哪里比拟耗时。最终发现,sort函数占用了大量的工夫,因为有2层for循环。从新查看代码,其实call回来的api在后端解决的时候,其实曾经是排好程序的,因而,前端无需“多此一举”。综上所述,删除前端sort函数即可。(省略后续测试步骤......)【知识点回顾】 curl 是罕用的命令行工具,用来申请 Web 服务器。它的名字就是客户端(client)的 URL 工具的意思。有很多不同的命令行参数,不便开发者在cmd里申请api。

January 18, 2023 · 1 min · jiezi

关于curl:curl安装

一:windows下装置curl1:下载windows版本curl安装包依据你电脑的零碎抉择32位或64位,因为我的电脑是64位的,所以我抉择64位的安装包 curl下载地址:https://curl.haxx.se/download... 2:装置curl(1)将下载下来的压缩包解压到你想要装置的目录下,找到curl目录下的curl.exe文件 (2)将curl.exe文件所在门路退出到环境变量中,这是为了curl命令能够全局应用 (3)新建一个CURL_HOME变量,变量地址为curl.exe文件所在门路 (4)将CURL_HOME变量信息加到PATH变量中 3:判断curl是否装置胜利curl --version 装置胜利 二:linux下装置curl1:下载curl下载地址:https://curl.haxx.se/download... 你也能够下载旧版的curl:https://curl.haxx.se/download/ wget https://curl.haxx.se/download/curl-7.30.1.tar.gz2:装置curltar -xzvf  curl-7.30.1.tar.gz #解压cd curl-7.30.1./configuremake && make install3:检测是否装置胜利curl --version

November 1, 2022 · 1 min · jiezi

关于curl:国密curl的用法指南

1.curl是什么 cURL(客户端URL)是一个凋谢源代码的命令行工具,用来申请 Web和其余各种类型的服务器。curl有着大量的参数,罕用来测试/调试服务器的开发和排查等,堪称一个网络“神器”。 2.国密curl是什么 curl本身不反对国密SSL协定(TLCP)。程序员说:要有国密版curl,于是就有了国密版curl,哈哈,程序员就是软件世界的上帝啊。国密版curl,简称gmcurl,由国密SSL实验室(www.gmssl.cn)移植,并提供收费下载和应用。 3.国密curl应用(单向国密SSL)3.1 简略执行[root@206test ~]# ./gmcurlGM Version: 1.0.0 Ported by www.gmssl.cnOptions:--gmssl, use TLCP protocol--cert, use sm2 sig pem cert--key, use sm2 sig pem key--cert2, use sm2 enc pem cert--key2, use sm2 enc pem keycurl: try 'curl --help' or 'curl --manual' for more information3.2 简略拜访[root@206test ~]# ./gmcurl --gmssl -k https://ebssec.boc.cnGM Version: 1.0.0 Ported by www.gmssl.cnOptions:--gmssl, use TLCP protocol--cert, use sm2 sig pem cert--key, use sm2 sig pem key--cert2, use sm2 enc pem cert--key2, use sm2 enc pem key正文:1)--gmssl示意启用国密SSL2)-k示意不验证服务端证书 ...

July 20, 2022 · 17 min · jiezi

关于curl:cURL-作者回怼财富-500-强公司的白嫖要求-不付钱就闭嘴

近日,cURL 的作者 Daniel Stenberg 公布的一篇推文引起了热议。文中,他礼貌的“回怼”了来自500强公司对其技术支持“白嫖”的无理要求——“要么付钱,要么闭嘴!” 据悉,该事件的起因是一家美国《财产》500 强公司因去年 12 月份的 Apache Log4j 破绽事件,而发来了一封电子邮件(该公司或其客户可能正在应用 cURL)询问一系列问题,以理解 cURL 是否依赖于 Log4j,并要求 cURL 的作者须在收到这封邮件的 24 小时内尽快、收费地回复。 该邮件原文下方,这家财产 500 强公司(以NNNN代表)还列出了一系列有待 cURL 的作者 Daniel Stenberg 答复的问题: 贵公司是否产生过任何经证实的安全事件?如果有,哪些应用程序、产品、服务和相干版本受到影响?是否有任何 NNNN 的产品和服务受到影响?NNNN 非公开信息或个人信息是否受到影响?如果是,请立刻向 NNNN 提供受影响信息的细节。实现补救措施的时间表是什么?列出这些步骤,并包含每个步骤的日期。须要 NNNN 采取什么口头来实现这一补救措施?…… 收到这封邮件之后,cURL 的作者 Daniel Stenberg 感到非常好笑,因为他从未参加过任何 Log4j 的开发工作,也就是他和这件事件没有一点儿关系。 但既然邮件里要求他必须尽快回复,因而他也礼貌而“克服”的做了回答:“只有咱们签订了反对合同,我就会立刻回信”。同时,他也将对该事件放在了推特上“吐槽”: “如果你是一家价值数十亿美元的公司,当你关怀 Log4j 的时候,为什么不给那些你从未领取过任何费用的 OSS 作者发邮件要求他们在 24 小时内收费回复大量信息并出示收到的邮件呢?” cURL 作者“回怼”:邮件里的内容无知水平令人震惊可能是这件事件真的有点太莫名其妙了, Daniel Stenberg 随后还专门写了一篇博文评估这件事件: “2022 年 1 月 21 日星期五,我收到了这封电子邮件。我在推特上发了这条音讯,而后来到了。 这封邮件来自一家价值数十亿美元的《财产》500强公司,该公司显然可能会应用蕴含我的代码的产品,或者他们可能有这样的客户。谁晓得呢? 我猜他们这样做是出于法规听从性的起因,他们“遗记”了他们的开源组件不是由“合作伙伴”主动提供的,他们能够简略地要求提供这些信息。 我很简短地回复了这封邮件,并示意一旦咱们签订了反对合同,我很乐意回复详细信息。 我认为这可能是开源金字塔模式的一个很好的例子,高层的人基本不思考如何保护底层。不必放心房子所在的高空就能够盖房子。” ...

January 26, 2022 · 1 min · jiezi

关于curl:curl-作者-Daniel-Stenberg-计划将为-curl-添加原生支持-JSON

近日,curl 作者 Daniel Stenberg 打算将为 curl 增加原生反对 JSON ,并给出了三个理由。 在 REST APIs 等畛域,发送 JSON 是很广泛的做法当被问及人们抉择 curl 代替计划的思考因素时,“易于应用 JSON”是常见的答案在 Stack Overflow 等网站上,因为 JSON 应用了双引号,而 Shell 不会在单引号内扩大变量从而导致许多人无奈应用 cURL 发送正确的 JSON 和正确援用 JSONDaniel 示意,因为他不常常发送 JSON,所以不适宜齐全靠他来设计这个性能。他须要更多其他人的帮忙来让这个性能尽可能地有用。 简略来说,Daniel 打算减少两个命令行选项: 发送已格式化的 JSON 作为 -d 的快捷方式,并附带相匹配的 Accept header构建 JSON request body 进行发送目前 Daniel 曾经在curl wiki中起草了他更新的概念,同时创立了讨论区。感兴趣的敌人们能够积极参与探讨。 curl wiki 链接:https://github.com/curl/curl/... 讨论区链接:https://github.com/curl/curl/... 对于 cURLcURL是一个开源我的项目,次要的产品是curl(命令行工具)和libcurl(C语言的API库),两者性能均是:基于网络协议,对指定URL进行网络传输。 curl 是一款利用 URL 语法在命令行下工作的文件传输工具,1997 年首次发行。它反对文件上传和下载,所以是一款综合传输工具。curl 蕴含用于程序开发的 libcurl,可解决各种状况的认证页面,如交互式的让用户输出明码等,目前可在MIT许可证下应用。

January 22, 2022 · 1 min · jiezi

关于curl:php-curl-请求https接口证书问题

php 在windows上面应用curl申请一个https须要配置证书,具体请看代码: php.ini配置 证书下载http://curl.haxx.se/ca/cacert...

December 18, 2021 · 1 min · jiezi

关于curl:命令行搞一切之curl-的开心应用

查看本人的外网ip地址很多网站都提供这个性能,如: curl -s ip.liquidweb.comcurl checkip.amazonaws.comcurl ifconfig.mecurl httpbin.org/ip生成一个二维码网址是 qrenco.de,即 QR encode,是不是很好记呢。 % curl qrenco.de/bixuebihui.com██████████████████████████████████████████████████████████████ ▄▄▄▄▄ █ ▄ █ █ ▄▄▄▄▄ ████████ █ █ █ ▀▀ █ █ █ ████████ █▄▄▄█ █▀▀██ █ █▄▄▄█ ████████▄▄▄▄▄▄▄█▄▀ █▄█▄▄▄▄▄▄▄████████ ▀▀ ▄▄▀▀ █▄█▀█▄▀▄▄ ▄████████▀ █▄▀ ▄▀▄▀ █▀▀██ ██▄▀███████████▄▄█▄▄ ▀▀▄██▀█ ▄█ ▄████████ ▄▄▄▄▄ █▀▄▄█▀ █▀▄▄█ ▀████████ █ █ █▄▀▀█▄ ██▀ ▀▀▀████████ █▄▄▄█ █▀ ▀▀▄██ ████████████▄▄▄▄▄▄▄█▄██▄█▄█▄████▄██████████████████████████████████████████████████████████████生成是显示在页面上看上去有点问题,命令行里还是能够扫到的。 查个字典curl dict.org/d:entropy |lesscurl dict.org/d:curl |less抽奖时搞个偏心随机数curl "https://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new"打小抄curl http://cht.sh/java会返回罕用的java的一些应用提醒。 如 curl http://cht.sh/js/promise/* * understanding javascript promise object * * Promise execution is asynchronous, which means that it's executed, but * the program won't wait until it's finished to continue with the rest * of the code. * * Basically, your code is doing the following: * * 1. Log 'Hi' * 2. Create a promise * 3. Execute the promise * 4. Log 'zami' * 5. Promise is resolved and logs 'There'. * If you want it to print 'Hi there, zami', you will have to */myPromise.then(function (result) { // Resolve callback. console.log(result); console.log('zami');}, function (result) { // Reject callback. console.error(result);});/* [Alberto Rivera] [so/q/39458201] [cc by-sa 3.0] */中文OCR辨认这个网站有收费可用的api: https://ocr.space/OCRAPI通过curl简略调用能够辨认图片上的文字,能够指定语言。免费版每天可用500次,文件最大1M。反对20几种语言,包含中文。 ...

September 19, 2021 · 3 min · jiezi

关于curl:curl网站开发指南

curl是一种命令行工具,作用是收回网络申请,而后失去和提取数据,显示在"规范输入"(stdout)下面。 它反对多种协定,上面举例解说如何将它用于网站开发。 一、查看网页源码 间接在curl命令后加上网址,就能够看到网页源码。咱们以网址www.sina.com为例(抉择该网址,次要因为它的网页代码较短): curl www.sina.com<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html> <head> <title>301 Moved Permanently</title> </head> <body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://www.sina.com.cn/">here</a>.</p> </body></html>如果要把这个网页保留下来,能够应用-o参数,这就相当于应用wget命令了。 curl -o [文件名] www.sina.com二、主动跳转 有的网址是主动跳转的。应用-L参数,curl就会跳转到新的网址。 curl -L www.sina.com键入下面的命令,后果就主动跳转为www.sina.com.cn。 三、显示头信息 -i参数能够显示http response的头信息,连同网页代码一起。 curl -i www.sina.com HTTP/1.0 301 Moved Permanently Date: Sat, 03 Sep 2011 23:44:10 GMT Server: Apache/2.0.54 (Unix) Location: http://www.sina.com.cn/ Cache-Control: max-age=3600 Expires: Sun, 04 Sep 2011 00:44:10 GMT Vary: Accept-Encoding Content-Length: 231 Content-Type: text/html; charset=iso-8859-1 Age: 3239 X-Cache: HIT from sh201-9.sina.com.cn Connection: close <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://www.sina.com.cn/">here</a>.</p> </body></html>-I参数则是只显示http response的头信息。 ...

June 12, 2021 · 2 min · jiezi

关于curl:通过CURL获取本机指定IP-地址相关信息

curl获取本机代理IP地址 $curl ip.sb101.*.*.112$curl ip.gs101.*.*.112curl获取IP地址+地区 $curl ipinfo.io{ "ip": "101.*.*.112", "city": "Kowloon", "region": "Kowloon City", "country": "HK", "loc": "22.3167,114.1833", "org": "AS132203 Tencent Building, Kejizhongyi Avenue", "timezone": "Asia/Hong_Kong", "readme": "https://ipinfo.io/missingauth"}% curl获取本机IP地址 $curl cip.ccIP : 125.*.*.87地址 : 中国 天津运营商 : 联通数据二 : 天津市 | 联通数据三 : URL : http://www.cip.cc/125.*.*.87curl查问指定IP信息 $curl cip.cc/114.114.114.114IP : 114.114.114.114地址 : 114DNS.COM 114DNS.COM数据二 : 江苏省南京市 | 南京信风网络科技有限公司GreatbitDNS服务器数据三 : 中国江苏南京URL : http://www.cip.cc/114.114.114.114$curl cip.cc/127.0.0.1IP : 127.0.0.1地址 : 本机地址 本机地址数据二 : 本机地址数据三 : 内网IP | 内网IPURL : http://www.cip.cc/127.0.0.1

April 6, 2021 · 1 min · jiezi

关于curl:failed-to-connect-to-rawgithubcom-port-443

curl: (7) failed to connect to raw.github.com port 443: connection refused 如何解决? 1、 2、网络 -> 高级 3、批改dns:8.8.8.8 done!

January 29, 2021 · 1 min · jiezi