curl 介绍和基本用法

PHP 的 curl 功能扩展基本用法 php的curl扩展工能基本使用方法... 阅读详情
 
curl是一个广泛使用的用来上传和下载的命令行工具,当然严格来讲,它还可以有别的用途。对于测试来讲,它是Web相关测试非常实用的工具,包括debugging,使用起来非常方便。而且另一方面,因为它是纯命令行的工具,所以也可以非常方便的作为一个组件集成到automation或者其他的测试框架里面,将HTTP/HTTPS/FTP相关的上传和下载等任务交给它。
最近因为在做web service相关的测试,用到了curl,觉得还不错,顺便给大家介绍一下。
 
official site: http://curl.haxx.se/ , 目前最新的版本是7.20.0。


基本的用法示例

curl http://www.google.com

curl dict://dict.org/d:test

下面主要介绍一下常用的参数,关于这方面,可以查看它自带的帮助文档。
-V show the version of curl
C:/Tools/curl-7.20.0>curl -V
curl 7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Protocols: dict file ftp ftps http https imap imaps ldap pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS Largefile NTLM SSL SSPI libz



-o [filename], save content to a file
-O use the same name

curl -o g.html www.google.com

curl -O http://www.google.com/intl/en_ALL/images/logo.gif


-i, Include the HTTP-header in the output     
curl -i http://www.google.com

-u username:password
curl -u user:pwd ftp://myftp/Ricky/test.ini

 

-d parameters
curl http://www.yahoo.com/login.cgi?user=nick&password=12345
curl -d "user=nick&password=12345" http://www.yahoo.com/login.cgi


-x  proxy_ip:port, access with proxy

curl -i -x myproxy:8080 -o google_proxy.html http://www.google.com

 

HTTP/1.1 302 Found
Via: 1.0 myproxy
Content-Length: 222
Date: Mon, 22 Mar 2010 14:15:48 GMT
Location: http://www.google.com.tw/
Content-Type: text/html; charset=UTF-8
Cache-Control: private
Set-Cookie: PREF=ID=aa97c3734c862ddf:TM=1269267348:LM=1269267348:S=4FEEGAPNu2FN2lho; expires=Wed, 21-Mar-2012 14:15:48 GMT; path=/; domain=.google.com
Set-Cookie: NID=32=MXKkZjgjiNGVNnPv9w384COa2KJZOLu5v9_5coX_N1tJtaa97-dJUxb7DCz90vQsm0fLEPg0Ee3nXv1yDDcE3ZN0sOu7mq9-mjB9CL0okXGjiIvox2FTcw0HBV7hBaLC; expires=Tue, 21-Sep-2010 14:15:48 GMT; path=/; domain=.google.com; HttpOnly
Server: gws
X-XSS-Protection: 0


<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com.tw/">here</A>.
</BODY></HTML>


-r [start-end], such as "-r 0-1024"

curl -i -r 0-1024 -o rfc1.txt http://xml.resource.org/public/rfc/bibxml3/rdf/item.I-D.6man-pmip6-ind.rdf

header:
HTTP/1.1 206 Partial Content
Date: Mon, 22 Mar 2010 13:50:46 GMT
Server: Apache/2.2.15 (Debian)
Last-Modified: Mon, 09 Mar 2009 23:02:11 GMT
ETag: "148be6-466-464b79fe1a2c0"
Accept-Ranges: bytes
Content-Length: 1025
Content-Range: bytes 0-1024/1126
Content-Type: application/rdf+xml

note: not all web server support partial content, or it will response all even you try to get part
curl -i -r 0-1024 http://www.sina.com.cn -o sina_part1.htm

it will give you all the page.

-k insecure SSL , will not check the cert

curl -k https://ip:8445

 

-T upload a file with FTP
curl -T curl.html -u user:pwd ftp://myftp/Ricky/
execute once again will overwrite


-F/--form <name=content>, use for http post

curl -F password=@/etc/passwd www.mypasswords.com

You can also tell curl what Content-Type to use by using 'type=', in a manner similar to:

curl -F "web=@index.html;type=text/html" url.com  


 
最后顺便说一下,如果是用来做HTTP的测试和调试,希望有GUI的话,也有不少其它的工具可以选择,包括Fiddler,JMeter和Firefox的tamper data插件。

 

 

时序分析28 - 时序预测 格兰杰因果关系(中) python实践1 时序分析28 - 时序预测 - 格兰杰因果关系(中) Python 实践 1 上一篇文章我们介绍了格兰杰因果关系的基本概念、背景以及相关统计检验法。本篇文章我们使用Python编程实践一下。 实践1:股票价格数据之间的格兰杰因果关系 问题:苹果公司今天的股价是否可以用来预测明天的特斯拉的股价? 数据:来自雅虎财经 import matplotlib.pyplot as plt import seaborn as sns import numpy as np import pandas as pd 读入数据 阅读详情

相关推荐

【学习体会】Lighttools8.4.0:简单光学系统实例

添加球型光源(SphereSource)和表面接收器: 对光线模拟的参数进行设置: 光线追踪-模拟输入 要追踪的光线总数,决定模拟的准确度,总数越多,准确度越高,当然耗时更多 预览光线数量是模拟之后可以看到的示意光线(黑线),一般是100~1000,随意设置 点击,开始模拟: (模拟结果) 如果光线太多,则会出现,可以看到剩余时间 照度分析: 分析-照度显示-光栅图表 ...

LeonJin的博客 1万+

curl命令用法详解

本文是一篇关于curl命令的详细教程,将介绍该命令的基础知识和实际应用。curl命令是一个非常强大的网络传输工具,可用于发送HTTP请求、下载文件、测试网络连接等。

swthink的博客 7369

FLUENT UDF编译及蒸发冷凝相关问题

蒸发冷凝与相间传质

weixin_48029137的博客 1万+

curl命令常用参数

curl用法大全

教Linux的李老师 2万+

Oracle-OGG trail 文件大小引起的进程异常 OGG-01172

监控OGG目标端进程,其中一个进程异常,状态为 ABENDED,start repa 执行失败。进入OGG报告目录检查运行报告 2015-04-20 09:38:36 ERROR OGG-01172 Discard file (/ogg/oggrm/11.2/dirdat/repa.dsc) exceeded max bytes (2000000000). 总结处理方法,从根本上解决问题。

xdyzgjy的专栏 7958

为什么我的Win11家庭版找不到BitLocker?教你两种强制关闭加密的隐藏方法

本文解释了Win11家庭版为何缺少BitLocker功能,并提供了两种强制关闭加密的隐藏方法。通过注册表修改和PowerShell命令,用户可以调出隐藏的加密控制面板或直接操控加密引擎,解决家庭版设备加密的管理难题。

weixin_42535703的博客 1812

curl使用总结

curl使用官网:https://curl.haxx.se/docs/manpage.html 1·、查看curl的安装版本以及支持的协议:$ curl -V 2、CURL分析HTTPS请求耗时时间: HTTPS耗时=TCP握手+SSL握手,因为涉及到一些加密,即多了几次握手交互,可以看到时间 要多于平常时间的3-5陪,当然也和机器性能相关: $: curl -w "TCP hands...

白清羽的博客 2万+

准确率、召回率、f1指标计算的区别

准确率是模型正确预测的样本占总样本的比例。

stephen147的博客 1418

curl常用命令的使用

curl常用参数 1、curl -k 再发送https请求时,加上-k参数,否则会有如下证书的报错 curl: (60) Peer's certificate issuer has been marked as not trusted by the user. More details here: http://curl.haxx.se/docs/sslcerts.html 2、curl -X(大写) 指定请求方法,如POST、GET等 curl -k -X POST https://www...

新雪兰 2万+

【系统架构设计师-2023年真题】综合知识-答案及详解

要实现多任务间的协同工作,操作系统必须提供任务间的通信手段。嵌入式操作系统一般都会提供多任务间通信的方法,其中()是任务间最直接、最明显的通信方法,也是访问共享的数据结构,即不同的任务都可以访问同一地址空间。()作为一种更高级的通信方式,能够在同一处理器的各个任务间传递任意长度(理论上只受物理内存和机器字长限制)的信息。(1)A. 共享内存 B. Socket C. 消息传递 D. 信号量(2)A. 共享内存 B. Socket C. 消息传递 D. 信号量【答案】A、C关于星型拓扑结构,下列说法正确的是(

数据知道的博客 1万+

训练YOLOv11 | Pytorch和Pycharm的安装教程适用W11系统(附详细的系统变量添加过程)

根据你之前下载的版本选择对应的选项即可,然后复制底下的绿色代码到Anaconda的命令行输入即可(这里要在你安装的python环境里进行安装,例如我的环境名字是PyTorch,那么就是activate PyTorch里进行安装)然后同之前一样会加载一会,然后会询问我们是否下载配件,我们输入Y等待即可(下载过程中我们要确保网络通常如果有波动可能会下载失败)。类似于我的电脑是Windows11选择上面红框内的选项即可点击后即下载,(注意这里下载的是zip文件)下载完成后复制下面几个文件。

Snu77的博客 1万+

curl命令详解

curl参数 -X 指定请求方法 -x 指定HTTP请求的代理 -H 指定请求标头 -d 发送POST请求提交的数据,使用-d参数后,会自动将请求转为POST,HTTP请求会自动加上标头Content-Type : application/x-www-form-urlencoded,可省略-X POST -v 显示http通信的整个过程 -u 设置服务器认证的用户名和密码 -i 显示Respons...

holmes369的博客 8562

滑块逆向及流程分析

本文章中所有内容仅供学习交流使用,不用于其他任何目的,不提供完整代码,抓包内容、敏感网址、数据接口等均已做脱敏处理,严禁用于商业用途和非法用途,否则由此产生的一切后果均与作者无关!

pyzzd的博客 8017

强大的curl命令的介绍和一般用法

curl,全称CommandLine URL 或 CommandLine Uniform Resource Locator,顾名思义,curl命令是在命令行方式下工作,利用URL的语法进行数据的传输或者文件的传输。 这个命令行工具现在多用于Unix和Linux操作系统,是一个开源的工具,功能十分强大。

deliciousion的博客 8万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

curl http请求基本用法

从curl的一个使用实例说起: 将以下代码拷贝到命令行即可执行 curl -X POST \ http://jd.dev.imdada.cn/pickup/addOrder/ \ -H 'cache-control: no-cache' \ -H 'content-type: application/json' \ -H 'postman-token: 2f6b7816-...

阿俊的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

linux curl命令ftp用法,强大的curl命令的介绍和一般用法

curl,全称CommandLine URL 或 CommandLine Uniform Resource Locator,顾名思义,curl命令是在命令行方式下工作,利用URL的语法进行数据的传输或者文件的传输。这个命令行工具现在多用于Unix和Linux操作系统,是一个开源的工具,功能十分强大。下面是crul的官方网站,我们可以该网站获取该工具的最新版本,还有最全面的使用方法。从官网我们可以知...

weixin_36330387的博客 1449

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

php curl setopt 用法,curl_setopt函数介绍与使用方法详解

本文主要介绍了PHP中curl_setopt函数用法,以实例形式分析了curl_setopt函数的功能、定义、用途及相关的使用技巧。希望对大家有所帮助。具体分析如下:curl_setopt函数是php中一个重要的函数,它可以模仿用户的一些行为,如模仿用户登录,注册等等一些用户可操作的行为哦。bool curl_setopt (int ch, string option, mixed value)c...

weixin_29958449的博客 1251

curl常见用法

本文主要介绍curl的常见用法。说明:本文介绍的curl常见用法是面向Linux操作系统的。引用Manual中关于curl的介绍,内容如下:引用GitHub中关于curl的介绍,内容如下:curl is used in command lines or scripts to transfer data. curl is also used in cars, television sets, routers, printers, audio equipment, mobile phones, tablets,

liitdar的博客 2万+

curl

什么是curl命令? curl是利用URL语法在命令行方式下工作的开源文件传输工具。它被广泛应用在Unix、多种Linux发行版中,并且有DOS和Win32、Win64下的移植版本。 如何在windows下使用curl命令? 第一步: 进入curl下载官网,下载合适的版本,我这里下载的是windows 64位的curl。 其中我下载的zip文件。 另外CAB文件也是压缩文件,这...

曾经 1万+

curl命令行介绍

1.CURL介绍 CURL,全称Command Line URL Viewer,是一个Linux命令行工具,能从服务器下载数据,也能往服务器上发送数据,支持多种协议,支持的协议有:DICT,FILE,FTP,FTPS,GOPHER,HTTP,HTTPS,IMAP,IMAPS,LDAP,LDAPS,POP3,POP3S,RTMP,RTSP,SCP,SFTP,SMB,SMBS,SMTP,SMTPS,TELNET和TFTP。从CURL支持的协议就可以看出,CURL命令非常强大。 2.CURL 命令用法 2.1 c

qq_44516871的博客 2565

curl基本用法

curl 是一种命令行工具,作用是发出网络请求,然后获取数据,显示在"标准输出"(stdout)上面。 以下是博主整理的一些关于curl命令的基本用法。 -A/--user-agent <string> 设置用户代理发送给服务器 -b/--cookie <name=string/file> cook...

DayDayUp的博客 595

CURL 的简单用法

CURL

weixin_43862793的博客 872

Curl的基本用法和API交互

Curl 是一个强大的命令行工具,用于发送和接收数据,通常用于与Web服务器交互。以下是 Curl 在不同场景下的基本用法:基本的 POST 请求: 通过POST请求发送数据(用户名和密码)到指定的URL。 返回数据包的详细信息: 参数会显示HTTP响应头。 使用 Cookie 进行请求: 参数用于指定发送的Cookie。 使用自定义HTTP头发送Cookie: 参数用于添加自定义头部。 发送JSON数据并使用Cookie: 这个命令结合使用了Cookie和JSON数

Themanager112的博客 681

Linux系统中curl命令的基本使用

Linux系统中curl命令的基本使用

jks212454的博客 3763
上一篇: 性能测试中单个虚拟用户的行为
下一篇: 写在New Testing第一期发布
rickyqiu-邱鹏
博客等级 码龄17年 642粉丝 85原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值