Curl的说明
curl_easy_setopt函数介绍

curl_easy_setopt函数介绍本节主要介绍curl_easy_setopt中跟http相关的参数。
注意本节的阐述都是以libcurl作为主体,其它为客体来阐述的。
1. CURLOPT_URL设置访问URL2. CURLOPT_WRITEFUNCTION,CURLOPT_WRITEDATA回调函数原型为:size_t function( void *ptr, size_t size, size_t nmemb, void *stream); 函数将在libcurl接收到数据后被调⽤,因此函数多做数据保存的功能,如处理下载⽂件。
CURLOPT_WRITEDATA ⽤于表明CURLOPT_WRITEFUNCTION函数中的stream指针的来源。
3. CURLOPT_HEADERFUNCTION,CURLOPT_HEADERDATA回调函数原型为 size_t function( void *ptr, size_t size,size_t nmemb, void *stream); libcurl⼀旦接收到http 头部数据后将调⽤该函数。
CURLOPT_WRITEDATA 传递指针给libcurl,该指针表明CURLOPT_HEADERFUNCTION 函数的stream指针的来源。
4. CURLOPT_READFUNCTION CURLOPT_READDATAlibCurl需要读取数据传递给远程主机时将调⽤CURLOPT_READFUNCTION指定的函数,函数原型是:size_t function(void *ptr, size_t size, size_t nmemb,void *stream). CURLOPT_READDATA 表明CURLOPT_READFUNCTION函数原型中的stream指针来源。
5. CURLOPT_NOPROGRESS,CURLOPT_PROGRESSFUNCTION,CURLOPT_PROGRESSDATA跟数据传输进度相关的参数。
PHP使用CURL详解

PHP使⽤CURL详解curl是PHP的⼀个扩展,利⽤该扩展可以实现服务器之间的数据或⽂件传输也就是说curl就是⼀个⼯具,⽤来做服务器之间数据、⽂件传输的⼯具⽤来采集⽹络中的html⽹页⽂件、其他服务器提供接⼝数据等开启curl扩展(1)在php.ini⾥⾯开启curl这个扩展(2)将PHP的安装路径保存到环境变量的系统变量中(环境变量之间的分隔符是英⽂的分号)(3)重启apache服务器(4)重启计算机curl的⼀些常⽤配置项(1)通过CURLOPT_RETURNTRANSFER配置项设置,是直接显⽰结果(echo)还是将结果返回(return)(2)针对https协议的请求,需要验证客户端的安全证书,通常都会跳过安全证书的验证(3) CURLOPT_HEADER是否返回header头信息封装的⼀个curl⽅法1:<?php/** 使⽤curl扩展发出http的get或post请求*/class HttpRequest{//url,请求的服务器地址private$url = '';//is_return,是否返回结果⽽不是直接显⽰private$is_return = 1;public function __set($p,$v){if(property_exists($this, $p)){$this->$p = $v;}}// 发出http请求的⽅法//参数:提交的数据,默认是空的public function send($data = array()){//1. 如果传递数据了,说明向服务器提交数据(post),如果没有传递数据,认为从服务器读取资源(get) $ch = curl_init();//2. 不管是get、post,跳过证书的验证curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);//3. 设置请求的服务器地址curl_setopt($ch, CURLOPT_URL, $this->url);//4. 判断是get还是postif(!empty($data)){curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, $data);}//5. 是否返回数据if($this->is_return===1){//说明返回curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$result = curl_exec($ch);curl_close($ch);return$result;}else{//直接输出curl_exec($ch);curl_close($ch);}}}封装的⼀个curl⽅法2:1//curl采集器2public function http_curl($url,$type='get',$res='json',$arr=''){3//1.初始化curl4$ch=curl_init();5//2.设置curl的参数6 curl_setopt($ch,CURLOPT_URL,$url);7 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);8if($type=='post'){9 curl_setopt($ch,CURLOPT_POST,1);10 curl_setopt($ch,CURLOPT_POSTFIELDS,$arr);11 }12//3.采集13$output=curl_exec($ch);14//4.关闭15 curl_close($ch);16//如果返回的值,是json格式,则转换成数组17if($res=='json'){18if(curl_errno($ch)){19//请求失败,返回错误信息20return curl_error($ch);21 }else{22//请求成功23return json_decode($output,true);24 }25 }26 }//http_curl endcurl模拟⽂件上传说明:PHP5.6之前的版本上传⽂件使⽤:@Php5.6之后的版本使⽤new CURLFile()这样其他服务器接收到数据之后,就可以移动了curl模拟cookie登录(1)我们访问服务器时,服务器会先在服务器端创建⼀个session⽂件,保存⽤户的信息,便于在多个页⾯共享数据,然后服务器会以setcookie的形式告诉客户端在⾃⼰⾝上创建cookie,保存session⽂件的名,以前使⽤浏览器访问服务器的时候,浏览器会在⾃⼰⾝上创建cookie⽂件,现在使⽤我们的服务器访问:cookie保存到哪⾥?CURLOPT_COOKIEJAR配置项设置,cookie保存到哪⾥(2)以后再访问服务器的时候,随⾝携带cookie(⾥⾯就是存储的session⽂件的名字),那么怎么找到这个cookie呢?CURLOPT_COOKIEFILE 配置项设置,每次请求时携带哪个cookie⽂件PHP使⽤CURL详解CURL是⼀个⾮常强⼤的开源库,⽀持很多协议,包括HTTP、FTP、TELNET等,我们使⽤它来发送HTTP请求。
CURL使用指南说明书

Table of ContentsAbout1 Chapter 1: Getting started with curl2 Remarks2 Examples2 Transfer data using curl2 Using curl in PHP to fetch data2 Using curl through the command line2 Use the libcurl easy C API to get a remote resource3 Chapter 2: Curl Installation4 Examples4 From packages4 Chapter 3: Name resolve curl tricks5 Examples5 Editing the hosts file5 Providing custom IP address for a name5 Change the "Host:" header5 Credits7AboutYou can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: curlIt is an unofficial and free curl ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official curl.The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners.Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to ********************Chapter 1: Getting started with curlRemarksThis section provides an overview of what curl is, and why a developer might want to use it.It should also mention any large subjects within curl, and link out to the related topics. Since the Documentation for curl is new, you may need to create initial versions of those related topics. ExamplesTransfer data using curlcURL is the name of the project which depicts: 'Client for URLs' and also be called as Client URL Request Libraryit combines two separate packages: curl and libcurl.1.curl is a command line tool used to get documents/files from or send documents to a server, using any of the supported protocols: DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS,IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMTP,SMTPS, Telnet and TFTP.2.libcurl is the underlying library curl uses to do the actual networking and transfer work.libcurl is used by thousands of services, applications and devices and very often through one of the "language bindings" that allows programmers of higher level languages to access its powers.Using curl in PHP to fetch data<?php$ch = curl_init(); //curl handler initcurl_setopt($ch,CURLOPT_URL,"/search?q=curl");curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);// set optional paramscurl_setopt($ch,CURLOPT_HEADER, false);$result=curl_exec($ch);curl_close($ch);echo $result;>Using curl through the command lineShow curl version:curl --versionGET a remote resource and have it displayed in the terminal:curl GET a remote resource and save it in a local file:curl -o file https://Add headers to response:curl -i Output only headers:curl -I Use the libcurl easy C API to get a remote resource#include <stdio.h>#include <curl/curl.h>int main(void){CURL *curl;CURLcode res;curl = curl_easy_init();if(curl) {curl_easy_setopt(curl, CURLOPT_URL, "");/* is redirected, so we tell libcurl to follow redirection */curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);/* Perform the request, res will get the return code */res = curl_easy_perform(curl);/* Check for errors */if(res != CURLE_OK)fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));/* always cleanup */curl_easy_cleanup(curl);}return 0;}Read Getting started with curl online: https:///curl/topic/4246/getting-started-with-curlChapter 2: Curl InstallationExamplesFrom packagesThe curl source packages can be downloaded from the following page:https://curl.haxx.se/download.htmlHowever, the best way to install it is to use your package repository.For Linux distros, you can use apt-get, yum or rpm depending on the distribution you are using, so the exact command will be:apt-get install curlOr:yum install curlFor Mac users, you can install curl via Homebrew. More details here:/CurlRead Curl Installation online: https:///curl/topic/10591/curl-installationChapter 3: Name resolve curl tricksExamplesEditing the hosts fileThe easiest way to connect via curl to a different server is to alter the hosts file on your machine.On Linux and Unix systems, the hosts file is located in /etc/hosts, while on Windows systems it will be located in c:\windows\system32\drivers\etc\hosts.Once you open the file with a text editor of your choice, add1.2.3.4 domain.tld www.domain.tldThis is basically the IP of the server you would like to resolve the domain to followed by the domain and a www version of the domain.Curl will then resolve to this domain until the added line in the hosts file is removed.The limitation in this example is that editing the hosts file often requires admin access and also, it affects all applications connected to the domain at the same time.Providing custom IP address for a nameThe most effective way to resolve curl to a different server is to use the --resolve option. This option will insert the address into curl's DNS cache, so it will effectively make curl believe that's the address it got when it resolved the name. Like so:curl --resolve :80:1.2.3.4 /In the above example, firstly we specify the domain (), then we ask it to connect on port 80 to the IP 1.2.3.4. Depending on the protocol used and the server's configuration, the port can vary. For HTTP the port is 80 and for HTTPS, the port is 443.It is important to note here that the --resolve option will send SNI for the name in the URL. This means that when connecting to the server via HTTPS, curl will verify the server's response to make sure it servers for the name in the URL. In other words, it will ensure there is an SSL on the server installed for the domain.Change the "Host:" headerThe "Host:" header is a normal way an HTTP client tells the HTTP server which server it speaks to. By passing custom modified "Host:" header you can have the server respond with the content of the site, even if you didn't actually connect to the host name.For example, if you have a site on your localhost and you wish to have curl ask for its index page, the command is:curl -H "Host: " http://localhost/The main disadvantage of modifying the "Host:" header is that curl will only extract the SNI name to send from the given URL. In other words, the "Host:" header modification is not enough when communication with a server via HTTPS.Read Name resolve curl tricks online: https:///curl/topic/10565/name-resolve-curl-tricksCredits。
CURL的基本用法说明文档

CURL的基本用法说明文档(含详细代码)Curl基本用法总结如下:CURL是一个超强的命令行工具,其功能非常强大,有Linux/Unix版本的,也有Windows版本的,我平时就经常在Windows下面使用curl做一些测试,非常方便,有时用curl做测试比用浏览器做测试要快得多,方便得多。
1.curl命令帮助选项C:\>curl --helpUsage: curl [options...] <url>Options: (H) means HTTP/HTTPS only, (F) means FTP only-a/--append Append to target file when uploading (F)-A/--user-agent <string> User-Agent to send to server (H)--anyauth Tell curl to choose authentication method (H)-b/--cookie <name=string/file> Cookie string or file to read cookies from (H) --basic Enable HTTP Basic Authentication (H)-B/--use-ascii Use ASCII/text transfer-c/--cookie-jar <file> Write cookies to this file after operation (H)-C/--continue-at <offset> Resumed transfer offset-d/--data <data> HTTP POST data (H)--data-ascii <data> HTTP POST ASCII data (H)--data-binary <data> HTTP POST binary data (H)--negotiate Enable HTTP Negotiate Authentication (H)--digest Enable HTTP Digest Authentication (H)--disable-eprt Prevent curl from using EPRT or LPRT (F)--disable-epsv Prevent curl from using EPSV (F)-D/--dump-header <file> Write the headers to this file--egd-file <file> EGD socket path for random data (SSL)--tcp-nodelay Set the TCP_NODELAY option-e/--referer Referer URL (H)-E/--cert <cert[:passwd]> Client certificate file and password (SSL)--cert-type <type> Certificate file type (DER/PEM/ENG) (SSL)--key <key> Private key file name (SSL)--key-type <type> Private key file type (DER/PEM/ENG) (SSL)--pass <pass> Pass phrase for the private key (SSL)--engine <eng> Crypto engine to use (SSL). "--engine list" for list--cacert <file> CA certificate to verify peer against (SSL)--capath <directory> CA directory (made using c_rehash) to verifypeer against (SSL)--ciphers <list> SSL ciphers to use (SSL)--compressed Request compressed response (using deflate or gzip)--connect-timeout <seconds> Maximum time allowed for connection--create-dirs Create necessary local directory hierarchy--crlf Convert LF to CRLF in upload-f/--fail Fail silently (no output at all) on errors (H)--ftp-create-dirs Create the remote dirs if not present (F)--ftp-pasv Use PASV instead of PORT (F)--ftp-ssl Enable SSL/TLS for the ftp transfer (F)-F/--form <name=content> Specify HTTP multipart POST data (H) --form-string <name=string> Specify HTTP multipart POST data (H)-g/--globoff Disable URL sequences and ranges using {} and []-G/--get Send the -d data with a HTTP GET (H)-h/--help This help text-H/--header <line> Custom header to pass to server (H)-i/--include Include protocol headers in the output (H/F)-I/--head Show document info only-j/--junk-session-cookies Ignore session cookies read from file (H) --interface <interface> Specify network interface to use--krb4 <level> Enable krb4 with specified security level (F)-k/--insecure Allow curl to connect to SSL sites without certs (H)-K/--config Specify which config file to read-l/--list-only List only names of an FTP directory (F)--limit-rate <rate> Limit transfer speed to this rate-L/--location Follow Location: hints (H)--location-trusted Follow Location: and send authentication evento other hostnames (H)-m/--max-time <seconds> Maximum time allowed for the transfer --max-redirs <num> Maximum number of redirects allowed (H)--max-filesize <bytes> Maximum file size to download (H/F)-M/--manual Display the full manual-n/--netrc Must read .netrc for user name and password --netrc-optional Use either .netrc or URL; overrides -n--ntlm Enable HTTP NTLM authentication (H)-N/--no-buffer Disable buffering of the output stream-o/--output <file> Write output to <file> instead of stdout-O/--remote-name Write output to a file named as the remote file-p/--proxytunnel Operate through a HTTP proxy tunnel (using CONNECT) --proxy-anyauth Let curl pick proxy authentication method (H)--proxy-basic Enable Basic authentication on the proxy (H)--proxy-digest Enable Digest authentication on the proxy (H)--proxy-ntlm Enable NTLM authentication on the proxy (H)-P/--ftp-port <address> Use PORT with address instead of PASV (F)-q If used as the first parameter disables .curlrc-Q/--quote <cmd> Send command(s) to server before file transfer (F)-r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server --random-file <file> File for reading random data from (SSL)-R/--remote-time Set the remote file's time on the local output--retry <num> Retry request <num> times if transient problems occur--retry-delay <seconds> When retrying, wait this many seconds between each --retry-max-time <seconds> Retry only within this period-s/--silent Silent mode. Don't output anything-S/--show-error Show error. With -s, make curl show errors when they occur --socks <host[:port]> Use SOCKS5 proxy on given host + port--stderr <file> Where to redirect stderr. - means stdout-t/--telnet-option <OPT=val> Set telnet option--trace <file> Write a debug trace to the given file--trace-ascii <file> Like --trace but without the hex output-T/--upload-file <file> Transfer <file> to remote site--url <URL> Spet URL to work with-u/--user <user[:password]> Set server user and password-U/--proxy-user <user[:password]> Set proxy user and password-v/--verbose Make the operation more talkative-V/--version Show version number and quit-w/--write-out [format] What to output after completion-x/--proxy <host[:port]> Use HTTP proxy on given port-X/--request <command> Specify request command to use-y/--speed-time Time needed to trig speed-limit abort. Defaults to 30-Y/--speed-limit Stop transfer if below speed-limit for 'speed-time' secs-z/--time-cond <time> Transfer based on a time condition-0/--http1.0 Use HTTP 1.0 (H)-1/--tlsv1 Use TLSv1 (SSL)-2/--sslv2 Use SSLv2 (SSL)-3/--sslv3 Use SSLv3 (SSL)--3p-quote like -Q for the source URL for 3rd party transfer (F)--3p-url source URL to activate 3rd party transfer (F)--3p-user user and password for source 3rd party transfer (F)-4/--ipv4 Resolve name to IPv4 address-6/--ipv6 Resolve name to IPv6 address-#/--progress-bar Display transfer progress as a progress bar2.查找页面源代码中的指定内容例如查找京东商城首页含有js的代码C:\>curl | find "js"% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed19 158k 19 31744 0 0 53531 0 0:00:03 --:--:-- 0:00:03 65947<s cript type="text/javascript" src="/201006/js/jquery-1.2 .6.pack.js"></script><script type="text/javascript" src="/201007/js/g.base.j s"></script>76 158k 76 121k 0 0 10763 0 0:00:15 0:00:11 0:00:04 7574<span><a href="/help/ziti/jiangsu.aspx#jssq" target="_blank">宿迁</a></span>99 158k 99 158k <span><a href="/hel p/ziti/jiangsu.aspx#jsnt" target="_blank0">南通</a></span>100 158k 100 158k 0 0 12557 0 0:00:12 0:00:12 --:--:-- 18859<script type="text/javascript" src="/201007/js/jd.lib.js"></script><script type="text/javascript" src="/201007/js/p.index.js"></script><script type="text/javascript" src="/wl.js" ></script>document.write(unescape("%3Cscript src='" + gaJsHost + "/ga.js' type='text/javascript'%3E%3C/script%3E"));2.发送POST请求a.传递一个参加时可以不用双引号C:\>curl -d action=get_basic_info http://localhost//apps/contact/www/mobile.php [{"contact_id":"3","last_update_time":"1285832338","md5":"7b682e0c3ed3b3bddb3219a533477224"},{"contact_id":"2","last_update_time":"1286529929","md5":"49ac542f51 19512682b72f1d44e6fe81"},{"contact_id":"1","last_update_time":"1285830870","md5" :"3926cb3b0320327c46430c6539d58e5e"}]b.传递多个参加时必须用双引号,否则会报错C:\>curl -d "action=edit&contact_id=2&name=testurl"http://localhost//apps/contact/www/mobile.php13.下载文件比如下载百度首页的内容为baidu.htmlC:\>curl -o baidu.html % Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 6218 100 6218 0 0 61564 0 --:--:-- --:--:-- --:--:-- 173k4.将网站产生的cookie内容写入到文件中用curl -c cookie.txt 产生的文件cookie.txt的内容如下:# Netscape HTTP Cookie File# /newsref/std/cookie_spec.html# This file was generated by libcurl! Edit at your own risk. TRUE / FALSE 2147483647 BAIDUID 3EC2799E83C7187A26CBBA67CCB 71822:FG=15.测试域名绑定输入命令C:\>curl -H "Host:" http://202.108.22.5/ip地址202.108.22.5是ping域名以后返回的ip地址。
目前为目最全的CURL中文说明CURL中参考文档

⽬前为⽬最全的CURL中⽂说明CURL中参考⽂档⽬前为⽬最全的CURL中⽂说明CURL⽬前为⽬最全的CURL中⽂说明了,学PHP的要好好掌握.有很多的参数.⼤部份都很有⽤.真正掌握了它和正则,⼀定就是个采集⾼⼿了.PHP中的CURL函数库(Client URL Library Function)curl_close — 关闭⼀个curl会话curl_copy_handle — 拷贝⼀个curl连接资源的所有内容和参数curl_errno — 返回⼀个包含当前会话错误信息的数字编号curl_error — 返回⼀个包含当前会话错误信息的字符串curl_exec — 执⾏⼀个curl会话curl_getinfo — 获取⼀个curl连接资源句柄的信息curl_init — 初始化⼀个curl会话curl_multi_add_handle — 向curl批处理会话中添加单独的curl句柄资源curl_multi_close — 关闭⼀个批处理句柄资源curl_multi_exec — 解析⼀个curl批处理句柄curl_multi_getcontent — 返回获取的输出的⽂本流curl_multi_info_read — 获取当前解析的curl的相关传输信息curl_multi_init — 初始化⼀个curl批处理句柄资源curl_multi_remove_handle — 移除curl批处理句柄资源中的某个句柄资源curl_multi_select — Get all the sockets associated with the cURL extension, which can then be ”selected”curl_setopt_array — 以数组的形式为⼀个curl设置会话参数curl_setopt — 为⼀个curl设置会话参数curl_version — 获取curl相关的版本信息curl_init()函数的作⽤初始化⼀个curl会话,curl_init()函数唯⼀的⼀个参数是可选的,表⽰⼀个url地址。
PHPCURL错误码说明

PHPCURL错误码说明curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));//⼀般不加<?phpreturn ['1'=>'CURLE_UNSUPPORTED_PROTOCOL (1) – 您传送给 libcurl 的⽹址使⽤了此 libcurl 不⽀持的协议。
可能是您没有使⽤的编译时选项造成了这种情况(可能是协议字符串拼写有误,或没有指定协议 libcurl 代码)。
','2'=>'CURLE_FAILED_INIT (2) – ⾮常早期的初始化代码失败。
可能是内部错误或问题。
','3'=>'CURLE_URL_MALFORMAT (3) – ⽹址格式不正确。
','5'=>'CURLE_COULDNT_RESOLVE_PROXY (5) – ⽆法解析代理服务器。
指定的代理服务器主机⽆法解析。
','6'=>'CURLE_COULDNT_RESOLVE_HOST (6) – ⽆法解析主机。
指定的远程主机⽆法解析。
','7'=>'CURLE_COULDNT_CONNECT (7) – ⽆法通过 connect() 连接⾄主机或代理服务器。
','8'=>'CURLE_FTP_WEIRD_SERVER_REPLY (8) – 在连接到 FTP 服务器后,libcurl 需要收到特定的回复。
此错误代码表⽰收到了不正常或不正确的回复。
指定的远程服务器可能不是正确的 FTP 服务器。
','9'=>'CURLE_REMOTE_ACCESS_DENIED (9) – 我们⽆法访问⽹址中指定的资源。
Curl常用函数介绍

Curl常⽤函数介绍⼀、LibCurl基本编程框架在基于LibCurl的程序⾥,主要采⽤callback function (回调函数)的形式完成传输任务,⽤户在启动传输前设置好各类参数和回调函数,当满⾜条件时libcurl将调⽤⽤户的回调函数实现特定功能。
下⾯是利⽤libcurl完成传输任务的流程: 1. 调⽤curl_global_init()初始化libcurl 2. 调⽤curl_easy_init()函数得到 easy interface型指针 3. 调⽤curl_easy_setopt()设置传输选项 4. 根据curl_easy_setopt()设置的传输选项,实现回调函数以完成⽤户特定任务 5. 调⽤curl_easy_perform()函数完成传输任务 6. 调⽤curl_easy_cleanup()释放内存 7. 调⽤curl_global_cleanup()释放所有资源在整过过程中设置curl_easy_setopt()参数是最关键的,⼏乎所有的libcurl程序都要使⽤它。
⼆、⼀些基本的函数1.CURLcode curl_global_init(long flags);描述: 这个函数只能⽤⼀次。
(其实在调⽤curl_global_cleanup 函数后仍然可再⽤) 如果这个函数在curl_easy_init函数调⽤时还没调⽤,它讲由libcurl库⾃动调⽤,所以多线程下最好主动调⽤该函数以防⽌在线程中curl_easy_init时多次调⽤。
注意:虽然libcurl是线程安全的,但curl_global_init是不能保证线程安全的,所以不要在每个线程中都调⽤curl_global_init,应该将该函数的调⽤放在主线程中。
参数:flags CURL_GLOBAL_ALL //初始化所有的可能的调⽤。
CURL_GLOBAL_SSL //初始化⽀持安全套接字层。
CURL_GLOBAL_WIN32 //初始化win32套接字库。
curl_easy_perform_返回值说明

75 字符转换失败 字符转换失败。
76 必须记录回调 需要字符转换功能。
77 CA 证书权限 读 SSL 证书出现问题(路径?访问权限? ) 。
78 URL 中引用资源不 URL 中引用的资源不存在。 存在
79 错误发生在 SSH SSH 会话期间发生一个未知错误。 会话
80 无法关闭 SSL 连 未能关闭 SSL 连接。 接
42 中止的回调 由回调终止。应用程序告知 cURL 终止运作。
43
内部错误 内部错误。由一个不正确参数调用了功能。
45
接口错误 接口错误。指定的外发接口无法使用。
47 过多的重定向 过多的重定向。cURL 达到了跟随重定向设定的最大限额 跟
48 无法识别选项 指定了未知 TELNET 选项。
49 TELNET 格式错误 不合式的 telnet 选项。
25 无法启动上传 FTP 无法 STOR 文件。服务器拒绝了用于 FTP 上传的 STOR 操作。
26
回调错误 读错误。各类读取问题。
27 内存分配请求失 内存不足。内存分配请求失败。 败
28
访问超时 操作超时。到达指定的超时期限条件。
30 FTP 端口错误 FTP PORT 失败。PORT 命令失败。并非所有的 FTP 服务 器支持 PORT 命令,请 尝试使用被动(PASV)传输代替!
227 行。
15
内部故障 FTP 无法连接到主机。无法解析在 227 行中获取的主机
IP。
17 设置传输模式为 FTP 无法设定为二进制传输。无法改变传输方式到二进 二进制 制。
18 文件传输短或大 部分文件。只有部分文件被传输。 于预期
19 RETR 命令传输完 FTP 不能下载/访问给定的文件, RETR (或类似)命令失
curl_easy_perform 返回值说明

curl_easy_perform 返回值说明转载自亮剑独步江湖response=curl_easy_perform(curl);response返回的状态值CURLE_OK: printf("send ok!\n");CURLE_HTTP_POST_ERROR: printf("post error!\n");CURLE_COULDNT_CONNECT: printf("cannot connect to server\n");CURLE_OK = 0, 0: no errorCURLE_UNSUPPORTED_PROTOCOL, 1: unsupported protocolCURLE_FAILED_INIT, 2: failed initCURLE_URL_MALFORMAT, 3: URL using bad/illegal format or missing URL CURLE_URL_MALFORMAT_USER, 4: unknown errorCURLE_COULDNT_RESOLVE_PROXY, 5: couldn't resolve proxy nameCURLE_COULDNT_RESOLVE_HOST, 6: couldn't resolve host nameCURLE_COULDNT_CONNECT, 7: couldn't connect to serverCURLE_FTP_WEIRD_SERVER_REPLY, 8: FTP: weird server replyCURLE_FTP_ACCESS_DENIED,CURLE_FTP_USER_PASSWORD_INCORRECT, 10: unknown errorCURLE_FTP_WEIRD_PASS_REPLY, 11: FTP: unknown PASS replyCURLE_FTP_WEIRD_USER_REPLY, 12: FTP: unknown USER replyCURLE_FTP_WEIRD_PASV_REPLY, 13: FTP: unknown PASV replyCURLE_FTP_WEIRD_227_FORMAT, 14: FTP: unknown 227 response format CURLE_FTP_CANT_GET_HOST, 15: FTP: can't figure out the host in the PASV responseCURLE_FTP_CANT_RECONNECT, 16: FTP: can't connect to server the response code is unknownCURLE_FTP_COULDNT_SET_BINARY, 17: FTP: couldn't set binary mode CURLE_PARTIAL_FILE, 18: Transferred a partial fileCURLE_FTP_COULDNT_RETR_FILE, 19: FTP: couldn't retrieve (RETR failed) the specified fileCURLE_FTP_WRITE_ERROR, 20: FTP: the post-transfer acknowledge response was not OKCURLE_FTP_QUOTE_ERROR, 21: FTP: a quote command returned error CURLE_HTTP_RETURNED_ERROR, 22: HTTP response code said errorCURLE_WRITE_ERROR, 23: failed writing received data to disk/application CURLE_MALFORMAT_USER, 24: unknown errorCURLE_UPLOAD_FAILED, 25: upload failed (at start/before it took off) CURLE_READ_ERROR, 26: failed to open/read local data fromfile/applicationCURLE_OUT_OF_MEMORY, 27: out of memoryCURLE_OPERATION_TIMEOUTED, 28: a timeout was reachedCURLE_FTP_COULDNT_SET_ASCII, 29: FTP could not set ASCII mode (TYPE A) CURLE_FTP_PORT_FAILED, 30: FTP command PORT failedCURLE_FTP_COULDNT_USE_REST, 31: FTP command REST failedCURLE_FTP_COULDNT_GET_SIZE, 32: FTP command SIZE failedCURLE_HTTP_RANGE_ERROR, 33: a range was requested but the server did not deliver itCURLE_HTTP_POST_ERROR, 34: internal problem setting up the POST CURLE_SSL_CONNECT_ERROR, 35: SSL connect errorCURLE_BAD_DOWNLOAD_RESUME, 36: couldn't resume downloadCURLE_FILE_COULDNT_READ_FILE, 37: couldn't read a file:// file CURLE_LDAP_CANNOT_BIND, 38: LDAP: cannot bindCURLE_LDAP_SEARCH_FAILED, 39: LDAP: search failedCURLE_LIBRARY_NOT_FOUND, 40: a required shared library was not found。
curl_easy_perform 返回值说明

curl_easy_perform 返回值说明转载自亮剑独步江湖response=curl_easy_perform(curl);response返回的状态值CURLE_OK: printf("send ok!\n");CURLE_HTTP_POST_ERROR: printf("post error!\n");CURLE_COULDNT_CONNECT: printf("cannot connect to server\n");CURLE_OK = 0, 0: no errorCURLE_UNSUPPORTED_PROTOCOL, 1: unsupported protocolCURLE_FAILED_INIT, 2: failed initCURLE_URL_MALFORMAT, 3: URL using bad/illegal format or missing URL CURLE_URL_MALFORMAT_USER, 4: unknown errorCURLE_COULDNT_RESOLVE_PROXY, 5: couldn't resolve proxy nameCURLE_COULDNT_RESOLVE_HOST, 6: couldn't resolve host nameCURLE_COULDNT_CONNECT, 7: couldn't connect to serverCURLE_FTP_WEIRD_SERVER_REPLY, 8: FTP: weird server replyCURLE_FTP_ACCESS_DENIED,CURLE_FTP_USER_PASSWORD_INCORRECT, 10: unknown errorCURLE_FTP_WEIRD_PASS_REPLY, 11: FTP: unknown PASS replyCURLE_FTP_WEIRD_USER_REPLY, 12: FTP: unknown USER replyCURLE_FTP_WEIRD_PASV_REPLY, 13: FTP: unknown PASV replyCURLE_FTP_WEIRD_227_FORMAT, 14: FTP: unknown 227 response format CURLE_FTP_CANT_GET_HOST, 15: FTP: can't figure out the host in the PASV responseCURLE_FTP_CANT_RECONNECT, 16: FTP: can't connect to server the response code is unknownCURLE_FTP_COULDNT_SET_BINARY, 17: FTP: couldn't set binary mode CURLE_PARTIAL_FILE, 18: Transferred a partial fileCURLE_FTP_COULDNT_RETR_FILE, 19: FTP: couldn't retrieve (RETR failed) the specified fileCURLE_FTP_WRITE_ERROR, 20: FTP: the post-transfer acknowledge response was not OKCURLE_FTP_QUOTE_ERROR, 21: FTP: a quote command returned error CURLE_HTTP_RETURNED_ERROR, 22: HTTP response code said errorCURLE_WRITE_ERROR, 23: failed writing received data to disk/application CURLE_MALFORMAT_USER, 24: unknown errorCURLE_UPLOAD_FAILED, 25: upload failed (at start/before it took off) CURLE_READ_ERROR, 26: failed to open/read local data fromfile/applicationCURLE_OUT_OF_MEMORY, 27: out of memoryCURLE_OPERATION_TIMEOUTED, 28: a timeout was reachedCURLE_FTP_COULDNT_SET_ASCII, 29: FTP could not set ASCII mode (TYPE A) CURLE_FTP_PORT_FAILED, 30: FTP command PORT failedCURLE_FTP_COULDNT_USE_REST, 31: FTP command REST failedCURLE_FTP_COULDNT_GET_SIZE, 32: FTP command SIZE failedCURLE_HTTP_RANGE_ERROR, 33: a range was requested but the server did not deliver itCURLE_HTTP_POST_ERROR, 34: internal problem setting up the POST CURLE_SSL_CONNECT_ERROR, 35: SSL connect errorCURLE_BAD_DOWNLOAD_RESUME, 36: couldn't resume downloadCURLE_FILE_COULDNT_READ_FILE, 37: couldn't read a file:// file CURLE_LDAP_CANNOT_BIND, 38: LDAP: cannot bindCURLE_LDAP_SEARCH_FAILED, 39: LDAP: search failedCURLE_LIBRARY_NOT_FOUND, 40: a required shared library was not found。
curl -k的详细说明

curl -k的详细说明
`curl -k` 是一个`curl`命令的选项,用于发送HTTP或HTTPS 请求时忽略SSL证书校验。
具体来说,`-k`选项会使`curl`在发出请求时不验证服务器的SSL证书。
当使用`curl`发送HTTPS请求时,默认情况下,`curl`会验证服务器的SSL证书。
这是一个安全机制,用于确保你与服务器之间的通信是加密和可信任的。
然而,在某些情况下,服务器的证书可能无法通过验证,或者你可能不关心验证证书的有效性。
在这种情况下,可以使用`-k`选项来忽略证书验证。
请注意,使用`-k`选项存在一定的安全风险。
通过忽略SSL证书验证,你无法确定你与服务器之间的连接是否受到中间人攻击。
因此,在使用`-k`选项时要特别小心,确保你信任目标服务器和网络环境。
cur命令参数-概述说明以及解释

cur命令参数-概述说明以及解释1.引言1.1 概述概述:Cur命令是一种在命令行界面下运行的工具,它提供了一种简单而强大的方式来执行各种网络请求。
Cur命令最初在Unix系统中使用,但现在已经在许多操作系统上得到了广泛的支持。
Cur命令使用HTTP协议来进行数据传输,它可以发送HTTP请求并接收服务器的响应。
Cur命令支持多种常见的HTTP方法,如GET、POST、PUT和DELETE等,并且可以通过设置不同的参数来定制请求的内容和属性。
概括而言,Cur命令是一个功能强大且灵活的工具,可以在命令行中轻松地执行各种HTTP请求。
无论是进行简单的数据获取,还是进行复杂的数据操作,Cur命令都可以满足需求并提供一种快速高效的解决方案。
在接下来的文章中,我们将深入探讨Cur命令的常用参数、高级用法、应用场景以及其优缺点等方面内容,帮助读者更好地理解和应用Cur命令。
同时,我们还将展望Cur命令的未来发展,探讨其在日益发展的网络技术中的潜力和前景。
通过本文的阅读,读者将会对Cur命令有一个全面而深入的认识,以便更好地利用它来解决实际问题。
1.2 文章结构文章将按照以下结构进行组织和呈现:1. 引言:首先介绍本篇文章的主题,对cur命令进行概述并解释其重要性和应用场景。
同时,也会提供本文的目的以及读者可以从本文中获得的收益。
2. 正文:2.1 cur命令的基本介绍:详细介绍cur命令的定义、功能和用途,包括其在命令行界面中的操作方式和常见的应用场景。
通过清晰的描述和示例,使读者能够了解cur命令的基本用法和操作步骤。
2.2 cur命令的常用参数:列举并解释cur命令中常用的参数和选项,包括其含义和使用方法。
提供实际应用案例,帮助读者理解参数的作用和使用场景,以及如何根据实际需求选择合适的参数进行操作。
2.3 cur命令的高级用法:介绍cur命令的一些高级特性和技巧,包括使用正则表达式、通配符等扩展功能,以及如何通过自定义脚本和配置文件实现自动化的cur命令操作。
curl head方法

curl head方法一、curl简介及使用场景1.1 curl的定义curl是一个功能强大的开源命令行工具,用于发送HTTP、HTTPS、FTP和其他协议的请求。
它支持数据的传输、文件的上传和下载,还可以模拟浏览器行为,发送表单数据等。
curl是一种非常便捷而强大的工具,被广泛用于调试和测试Web应用程序、进行API请求和数据抓取等任务。
1.2 curl的使用场景curl在网络编程和Web开发中有着广泛的应用场景,下面是一些常见的使用场景:1.API测试和调试:curl可以用来对API进行各种请求,包括GET、POST、PUT和DELETE等。
通过命令行发送请求,可以方便地查看API返回的数据和调试接口的问题。
2.文件上传和下载:curl可以通过HTTP或FTP协议上传和下载文件。
它支持断点续传和多线程下载,可以快速而稳定地传输大文件。
3.爬虫和数据抓取:curl可以模拟浏览器的行为,抓取网页内容和数据。
它支持自动填充表单、处理Cookie和Session等功能,非常适合进行网页数据的采集和处理。
4.命令行HTTP客户端:curl可以用作命令行下的HTTP客户端,发送各种类型的请求,查看响应头和响应体,并支持设置请求头、Cookies等。
二、curl head方法的含义和作用2.1 head方法的定义在HTTP协议中,head方法用于获取指定URL的响应头信息,而不包含响应体。
它可以用来检查URL的有效性、获取服务器的信息和查看资源的元数据等。
2.2 curl中的head方法通过curl命令的-i选项,我们可以发送一个head请求,并返回服务器的响应头。
下面是一个使用curl head方法的示例:curl -i -X HEAD这个命令会向发送一个head请求,并在控制台输出服务器的响应头。
2.3 curl head方法的作用curl head方法的作用如下:1.检查URL的有效性:通过发送head请求,可以检查URL是否正确和可访问。
散度与旋度的物理意义

散度与旋度的物理意义在物理学中,散度(Divergence)与旋度(Curl)是两个极其重要的概念,它们被广泛应用于电磁学、流体力学、热力学等领域。
散度和旋度作为向量场的两个性质,能够描述向量场在空间中的分布、流动和转动情况。
本文将阐述散度和旋度的物理意义以及它们在不同领域中的应用。
1. 散度的物理意义散度是一个向量场的量纲为每单位体积的矢量流量的发散度。
从物理意义上来看,散度描述了一个向量场在空间中产生的“源”和“汇”的情况。
在电磁学中,散度的具体含义就是电场在一个点上的电荷密度,即电荷线密度与该点体积的比值。
如果一个向量场的散度在某一点为正,那么该点就是“源”,此时向量场具有向此处流动的趋势;如果散度在某一点为负,那么该点就是“汇”,此时向量场具有向该点汇聚的趋势。
如果一个向量场的散度在某一点为零,那么该点就是“无源”的,意味着该点的状态没有任何源头或者汇点,也即是该点之处向量场没有任何流动的趋势。
2. 散度在不同领域中的应用在电磁学中,散度用于分析电场和磁场的分布情况。
在一个电场中,如果某一点的电场强度的散度为正,那么就说明该点有电荷存在;如果散度为负,那么说明该点存在反电荷,也就是导体。
在磁场中,散度为零,因此磁场线从一个点进入另一个点,就像一个环绕的形状。
在流体力学中,散度用于描述速度场的流量分布情况。
在一个流动的液体中,液体的流动速度就是液体速度场的向量。
如果一些流线以没有源头的方式流过一种流体,则它们的流线就是一个无源的液体流。
如果液体流体中存在源和汇,那么流体的散度就是流量相等。
如果液体流体没有任何源头或汇点,那么流体的散度就为零。
3. 旋度的物理意义旋度是一个向量场的旋转和涡旋程度的指示,用于描述矢量场的旋转、曲率和流体的旋转情况。
在物理学中,旋度表现了物理量的曲率,通常用来描述物质在空间中的自转。
旋度的物理意义主要表现在以下方面:在一个向量场中,如果某一点的旋度为零,那么该点则代表是一个纯粹或无旋力场,在流动中没有旋转。
grpc curl 示例

grpc curl 示例GRPC是一个高性能、开源的远程过程调用(RPC)框架,它使用HTTP/2协议进行通信,提供了诸多优点,比如双向流、流控制、头部压缩等。
如果你想使用curl来与一个gRPC服务进行交互,你需要使用一个专门的工具来模拟gRPC请求,因为curl本身并不支持gRPC。
一个常见的工具是grpcurl,它是一个命令行工具,可以用来发出gRPC请求并查看响应。
你可以通过以下步骤来安装grpcurl并使用它来与gRPC服务交互:1. 首先,安装grpcurl工具。
你可以在GitHub上找到它的源代码并按照说明进行安装。
2. 一旦安装好了grpcurl,你可以使用它来发出gRPC请求。
比如,你可以使用以下命令来列出一个gRPC服务的所有方法:grpcurl -plaintext -protoset <proto_file>.bin<host>:<port> list.这里,-plaintext表示使用不加密的连接,<proto_file>.bin是服务的proto文件编译生成的二进制文件,<host>:<port>是你要连接的gRPC服务的地址和端口。
3. 你还可以使用grpcurl来调用具体的gRPC方法。
比如,你可以使用以下命令来调用一个特定的方法:grpcurl -plaintext -d '{"<request_json>"}' -protoset <proto_file>.bin <host>:<port> <service>.<method>。
这里,-d表示发送的数据,<request_json>是你要发送的JSON格式的请求数据,<proto_file>.bin是服务的proto文件编译生成的二进制文件,<host>:<port>是你要连接的gRPC服务的地址和端口,<service>.<method>是你要调用的gRPC方法。
Ubuntu 13.10的安装使用之curl的使用说明

最新Ubuntu 13.10的安装使用之curl的使用说明安装好 ubuntu之后,进行下一步:一站式自动安装 rvm+ruby(感谢51cto张汉东老师指导):\curl -L https://get.rvm.io | bash -s stable --autolibs=3 --ruby 如果提示没有安装crul,则还要另外执行 \sudo apt-get install curl获取:1 /ubuntu/ saucy/main curl i386 7.32.0-1ubuntu1 [127 kB]如果再提示安装不了curl,则再重设源,在 ubuntu左侧“软件中心”点开之后上面的“编辑”里有,在打开的窗口里前边的两个选项卡里的内容全给它勾上。
重新设置了源之后,要刷新下:\sudo apt-get update然后再安装 curl: sudo apt-get install crul这个时候如果还是不行,那就再更换源,换几个试,最后很可能就行了,我就是这样试的,其它没作什么操作,最后也就OK了。
嗯,换过源之后别忘了 update最后运行上面的命令安装rvm+rubywanter@wanter-VirtualBox:~$ curl -L https://get.rvm.io | bash -s stable --autolibs=3 --ruby% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 184 100 184 0 0 98 0 0:00:01 0:00:01 --:--:-- 99100 19632 100 19632 0 0 7648 0 0:00:02 0:00:02 --:--:-- 86867Please read and follow further instructions.Press ENTER to continue.Downloading RVM branch stableDownloading https:///wayneeseguin/rvm/archive/stable.tar.gz to rvm-stable.tgz.% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 124 100 124 0 0 90 0 0:00:01 0:00:01 --:--:-- 90100 1083k 100 1083k 0 0 53015 0 0:00:20 0:00:20 --:--:-- 63558Installing RVM to /home/wanter/.rvm/Adding rvm PATH line to /home/wanter/.bashrc /home/wanter/.zshrc.Adding rvm loading line to /home/wanter/.bash_profile /home/wanter/.zlogin.Installation of RVM in /home/wanter/.rvm/ is almost complete:* To start using RVM you need to run `source /home/wanter/.rvm/scripts/rvm`in all your open shell windows, in rare cases you need to reopen all shell windows.# wanter,## Thank you for using RVM!# We sincerely hope that RVM helps to make your life easier and more enjoyable!!!## ~Wayne, Michal & team.In case of problems: http://rvm.io/helpHelp RVM 2.0: https:///fundraisers/489-rvm-2-0* WARNING: You have '~/.profile' file, you might want to load it,to do that add the following line to '/home/wanter/.bash_profile':source ~/.profilervm 1.23.10 (stable) by Wayne E. Seguin <wayneeseguin@>, Michal Papis <mpapis@> [https://rvm.io/]Searching for binary rubies, this might take some time.Found remote fileNo binary rubies available for: ubuntu/13.10/i386/ruby-2.0.0-p247.Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for ubuntu.Installing requirements for ubuntu.wanter password required for 'apt-get --quiet --yes update':wanter password required for 'apt-get --quiet --yes update':Updating system...................................................................................................................................................... Installing required packages: gawk, g++, libreadline6-dev, zlib1g-dev, libssl-dev, libyaml-dev, libsqlite3-dev, sqlite3, autoconf, libgdbm-dev, libncurses5-dev, automake, libtool, bison, libffi-dev.............................................................................................................................Requirements installation successful.Installing Ruby from source to: /home/wanter/.rvm/rubies/ruby-2.0.0-p247, this may take a while depending on your cpu(s)...ruby-2.0.0-p247 - #downloading ruby-2.0.0-p247, this may take a while depending on your connection...% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 10.3M 100 10.3M 0 0 149k 0 0:01:10 0:01:10 --:--:-- 151kruby-2.0.0-p247 - #extracting ruby-2.0.0-p247 to /home/wanter/.rvm/src/ruby-2.0.0-p247ruby-2.0.0-p247 - #extracted to /home/wanter/.rvm/src/ruby-2.0.0-p247Applying patch /home/wanter/.rvm/patches/ruby/2.0.0/logging.patch....ruby-2.0.0-p247 - #configuring................................................................................................................................................................. ..................................................................................................................................................................................... ................................................................................................................................................ruby-2.0.0-p247 - #post-configurationruby-2.0.0-p247 - #compiling................................................................................................................................................................... ..................................................................................................................................................................................... ..................................................................................................................................................................................... ..................................................................................................................................................................................... ................................................ruby-2.0.0-p247 - #installing.................................................................................................................................................................... ...........................................................................................................................Retrieving rubygems-2.1.9% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 355k 100 355k 0 0 87458 0 0:00:04 0:00:04 --:--:-- 91197Extracting rubygems-2.1.9 ...Removing old Rubygems files...Installing rubygems-2.1.9 for ruby-2.0.0-p247........................................................................................................................................................... ..............................................Installation of rubygems completed successfully.Saving wrappers to '/home/wanter/.rvm/wrappers/ruby-2.0.0-p247'........ruby-2.0.0-p247 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).ruby-2.0.0-p247 - #importing default gemsets, this may take time..................Install of ruby-2.0.0-p247 - #completeRuby was built without documentation, to build it run: rvm docs generate-riCreating alias default for ruby-2.0.0-p247.Recording alias default for ruby-2.0.0-p247.Creating default links/filesSaving wrappers to '/home/wanter/.rvm/bin'........* To start using RVM you need to run `source /home/wanter/.rvm/scripts/rvm`in all your open shell windows, in rare cases you need to reopen all shell windows.约一个多小时。
PHPCURLCURLOPT参数说明(curl_setopt)

PHPCURLCURLOPT参数说明(curl_setopt)CURLOPT_RETURNTRANSFER 选项:curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);如果成功只将结果返回,不⾃动输出任何内容。
如果失败返回FALSEcurl_setopt($ch, CURLOPT_RETURNTRANSFER,0); 或着不使⽤这个选项:如果成功只返回TRUE,⾃动输出返回的内容。
如果失败返回FALSEbool curl_setopt (int ch, string option, mixed value)curl_setopt()函数将为⼀个CURL会话设置选项。
option参数是你想要的设置,value是这个选项给定的值。
下列选项的值将被作为长整形使⽤(在option参数中指定):• CURLOPT_INFILESIZE : 当你上传⼀个⽂件到远程站点,这个选项告诉PHP你上传⽂件的⼤⼩。
• CURLOPT_VERBOSE : 如果你想CURL报告每⼀件意外的事情,设置这个选项为⼀个⾮零值。
• CURLOPT_HEADER : 如果你想把⼀个头包含在输出中,设置这个选项为⼀个⾮零值。
• CURLOPT_NOPROGRESS: 如果你不会PHP为CURL传输显⽰⼀个进程条,设置这个选项为⼀个⾮零值。
注意:PHP⾃动设置这个选项为⾮零值,你应该仅仅为了调试的⽬的来改变这个选项。
• CURLOPT_NOBODY : 如果你不想在输出中包含body部分,设置这个选项为⼀个⾮零值。
• CURLOPT_FAILONERROR : 如果你想让PHP在发⽣错误(HTTP代码返回⼤于等于300)时,不显⽰,设置这个选项为⼀⼈⾮零值。
默认⾏为是返回⼀个正常页,忽略代码。
• CURLOPT_UPLOAD: 如果你想让PHP为上传做准备,设置这个选项为⼀个⾮零值。
• CURLOPT_POST : 如果你想PHP去做⼀个正规的HTTP POST,设置这个选项为⼀个⾮零值。
散度的旋度

散度的旋度散度和旋度是向量场的两个重要概念。
它们分别描述了向量场的发散和旋转程度,对于研究流体力学、电磁学等领域具有重要的应用价值。
散度(Divergence)是一个标量,描述了向量场在某一点的流出或流入程度。
它可以用来描述流体在某一点的流量变化情况。
在三维空间中,散度的定义为:$%nabla Íot %boldsymbol{F}= %frac{%partial F_1}{%partial x} + %frac{%partialF_2}{%partial y} + %frac{%partial F_3}{%partial z}$,其中$%boldsymbol{F}$是一个向量场,$F_1, F_2, F_3$是它在$x, y, z$方向上的分量。
如果在某一点,向量场的散度为正,说明该点有流出现象;如果散度为负,说明该点有流入现象;如果散度为零,则说明该点既没有流入也没有流出。
散度的物理意义十分直观,它可以用来描述物质的密度变化情况,对于流体力学、热力学等领域具有广泛的应用。
旋度(Curl)是一个向量,描述了向量场在某一点的旋转程度。
它可以用来描述流体在某一点的旋转情况。
在三维空间中,旋度的定义为:$%nabla %times %boldsymbol{F} = ¾gin{vmatrix}%boldsymbol{i} & %boldsymbol{j}& %boldsymbol{k}%% %frac{%partial}{%partial x}& %frac{%partial}{%partial y} & %frac{%partial}{%partial z}%%F_1 & F_2 & F_3%end{vmatrix}$,其中$%boldsymbol{i}, %boldsymbol{j}, %boldsymbol{k}$是三个单位向量。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
curl求助编辑百科名片curl 图标1.curl是利用URL语法在命令行方式下工作的文件传输工具。
1.编辑本段概念它支持很多协议:FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE 以及LDAP。
curl同样支持HTTPS认证,HTTP POST方法, HTTP PUT方法, FTP上传, kerberos认证, HTTP上传, 代理服务器, cookies, 用户名/密码认证, 下载文件断点续传, 上载文件断点续传, http代理服务器管道(proxy tunneling), 甚至它还支持IPv6, socks5代理服务器, 通过http代理服务器上传文件到FTP服务器等等,功能十分强大。
Windows操作系统下的网络蚂蚁,网际快车(FlashGet)的功能它都可以做到。
准确的说,curl支持文件的上传和下载,所以是一个综合传输工具,但是按照传统,用户习惯称curl为下载工具。
curl是瑞典curl组织开发的,您可以访问: http://curl.haxx. se/获取它的源代码和相关说明。
鉴于curl在Linux上的广泛使用,IBM在AIX Linux Toolbox的光盘中包含了这个软件,并且您可以访问IBM网站:http://www- 1.ibm. com/servers/aix/products/aixos/linux/altlic.html 下载它。
curl的最新版本是7.18.0,IBM网站上提供的版本为7.9.3。
在AIX下的安装很简单,IBM网站上下载的rpm格式的包。
在http://curl.haxx. se/docs/ ,您可以下载到UNIX格式的man帮助,里面有详细的curl工具的使用说明。
curl的用法为:curl [options] [URL...]其中options是下载需要的参数,大约有80多个,curl的各个功能完全是依靠这些参数完成的。
具体参数的使用,用户可以参考curl的man帮助。
下面,本文就将结合具体的例子来说明怎样利用curl进行下载。
编辑本段设计方法获得页面使用命令:curl http://curl.haxx. se这是最简单的使用方法。
用这个命令获得了http://curl.haxx. se指向的页面,同样,如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地。
如果下载的是HTML文档,那么缺省的将不显示文件头部,即HTML文档的header。
要全部显示,请加参数-i,要只显示头部,用参数-I。
任何时候,可以使用-v 命令看curl是怎样工作的,它向服务器发送的所有命令都会显示出来。
为了断点续传,可以使用-r参数来指定传输范围。
获取表单在WEB页面设计中,form是很重要的元素。
Form通常用来收集并向网站提交信息。
提交信息的方法有两种,GET方法和POST方法。
先讨论GET方法,例如在页面中有这样一段:<form method="GET" action="junk.cgi"><input type=text name="birthyear"><input type=submit name=press value="OK"></form>那么浏览器上会出现一个文本框和一个标为“OK”的按钮。
按下这个按钮,表单就用GET 方法向服务器提交文本框的数据。
例如原始页面是在www.hotmail. com/when/birth.html看到的,然后您在文本框中输入1905,然后按OK按钮,那么浏览器的URL现在应该是:“www.hotmail.com/when/junk.cgi?birthyear=1905&press=OK”对于这种网页,curl可以直接处理,例如想获取上面的网页,只要输入:curl "www.hotmail. com/when/junk.cgi?birthyear=1905&press=OK"就可以了。
表单用来提交信息的第二种方法叫做POST方法,POST方法和GET方法的区别在于GET 方法使用的时候,浏览器中会产生目标URL,而POST不会。
类似GET,这里有一个网页:<form method="POST" action="junk.cgi"><input type=text name="birthyear"><input type=submit name=press value="OK"></form>浏览器上也会出现一个文本框和一个标为“OK”的按钮。
按下这个按钮,表单用POST方法向服务器提交数据。
这时的URL是看不到的,因此需要使用特殊的方法来抓取这个页面:curl -d "birthyear=1905&press=OK" www.hotmail. com/when/junk.cgi这个命令就可以做到。
1995年年末,RFC 1867定义了一种新的POST方法,用来上传文件。
主要用于把本地文件上传到服务器。
此时页面是这样写的:<form method="POST" enctype='multipart/form-data' action="upload.cgi"><input type=file name=upload><input type=submit name=press value="OK"></form>对于这种页面,curl的用法不同:curl -F upload=@localfilename -F press=OK URL这个命令的实质是将本地的文件用POST上传到服务器。
有关POST还有不少用法,用户可以自己摸索。
使用PUTHTTP协议文件上传的标准方法是使用PUT,此时curl命令使用-T参数:curl -T uploadfile www.uploadhttp. com/receive.cgicurl可以处理各种情况的认证页面,例如下载用户名/密码认证方式的页面(在IE中通常是出现一个输入用户名和密码的输入框):curl -u name:password www.secrets. com如果网络是通过http代理服务器出去的,而代理服务器需要用户名和密码,那么输入:curl -U proxyuser:proxypassword http://curl.haxx. se任何需要输入用户名和密码的时候,只在参数中指定用户名而空着密码,curl可以交互式的让用户输入密码。
引用有些网络资源访问的时候必须经过另外一个网络地址跳转过去,这用术语来说是:referer,引用。
对于这种地址的资源,curl也可以下载:curl -e http://curl.haxx. se daniel.haxx. se指定用户端有些网络资源首先需要判断用户使用的是什么浏览器,符合标准了才能够下载或者浏览。
此时curl可以把自己“伪装”成任何其他浏览器:curl -A "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" URL这个指令表示curl伪装成了IE5.0,用户平台是Windows 2000。
(对方服务器是根据这个字串来判断客户端的类型的,所以即使使用AIX也无所谓)。
使用:curl -A "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" URL此时curl变成了Netscape,运行在PIII平台的Linux上了。
COOKIESCookie是服务器经常使用的一种记忆客户信息的方法。
如果cookie被记录在了文件中,那么使用命令:curl -b stored_cookies_in_file www.cookiesite. comcurl可以根据旧的cookie写出新cookie并发送到网站:curl -b cookies.txt -c newcookies.txt www.cookiesite. com加密HTTP如果是通过OpenSSL加密的https协议传输的网页,curl可以直接访问:curl https://that.secure.server. comhttp认证如果是采用证书认证的http地址,证书在本地,那么curl这样使用:curl -E mycert.pem https://that.secure.server. comcurl非常博大,用户要想使用好这个工具,除了详细学习参数之外,还需要深刻理解http 的各种协议与URL的各个语法。
这里推荐几个读物:RFC 2616 HTTP协议语法的定义。
RFC 2396 URL语法的定义。
RFC 2109 Cookie是怎样工作的。
RFC 1867 HTTP如何POST,以及POST的格式。
编辑本段其它Curl是由美国国防部高级研究项目代理资助,马萨诸塞州科技学院的David A. Kranz开发的Web开发语言,HTML语言的创建者Tim Berners-Lee也参与其中,并扮演了重要的角色。
Curl语言是一种编程语言,它被设计用于编写网络程序。
它的目标是以一种单一的语言来取代HTML, Cascading Style Sheets(层叠样式表)and JavaScript , 虽然它目前并未在世界范围内被广泛使用,但在日本有一定的普及。
Curl不像HTML,它不是一种文本标记语言,但Curl语言既可以用于普通的文本显示,又可以用于实现大规模的客户端商业软件系统。
Curl不利的一面是:需要向客户端安装运行环境。
用Curl写的程序既可以运行于浏览器中,又可以像普通客户端程序那样独立于浏览器运行,运行前需要安装SurgeRTE。
"SurgeRTE"是一种与JA V A类似的跨平台运行环境(runtime environment,RTE),其中包含浏览器的插件。
它目前支持微软视窗(Microsoft Windows)操作系统和Linux操作系统, 据传苹果机版将在不久的未来发布。
Curl语言便于学习,编程效率高,是一种支持多重继承,范型等数据类型的面向对象编程语言。