⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 curl_easy_setopt.3

📁 harvest是一个下载html网页得机器人
💻 3
📖 第 1 页 / 共 3 页
字号:
user..TP.B CURLOPT_USERPWDPass a char * as parameter, which should be [user name]:[password] to use forthe connection. If both the colon and password is left out, you will beprompted for it while using a colon with no password will make libcurl use anempty password. \fICURLOPT_PASSWDFUNCTION\fP can be used to set your ownprompt function.When using HTTP and CURLOPT_FOLLOWLOCATION, libcurl might perform severalrequests to possibly different hosts. libcurl will only send this user andpassword information to hosts using the initial host name (unlessCURLOPT_UNRESTRICTED_AUTH is set), so if libcurl follows locations to otherhosts it will not send the user and password to those. This is enforced toprevent accidental information leakage..TP.B CURLOPT_PROXYUSERPWDPass a char * as parameter, which should be [user name]:[password] to use forthe connection to the HTTP proxy. If the password is left out, you will beprompted for it. \fICURLOPT_PASSWDFUNCTION\fP can be used to set your ownprompt function..TP.B CURLOPT_HTTPAUTHPass a long as parameter, which is set to a bitmask, to tell libcurl whatauthentication method(s) you want it to use. The available bits are listedbelow. If more than one bit is set, libcurl will first query the site to seewhat authentication methods it supports and then pick the best one you allowit to use. Note that for some methods, this will induce an extra networkround-trip. Set the actual name and password with the \fICURLOPT_USERPWD\fPoption. (Added in 7.10.6).RS.TP 5.B CURLAUTH_BASICHTTP Basic authentication. This is the default choice, and the only methodthat is in wide-spread use and supported virtually everywhere. This is sendingthe user name and password over the network in plain text, easily captured byothers..TP.B CURLAUTH_DIGESTHTTP Digest authentication.  Digest authentication is defined in RFC2617 andis a more secure way to do authentication over public networks than theregular old-fashioned Basic method..TP.B CURLAUTH_GSSNEGOTIATEHTTP GSS-Negotiate authentication. The GSS-Negotiate method was designed byMicrosoft and is used in their web aplications. It is primarily meant as asupport for Kerberos5 authentication but may be also used along with anotherauthentication methods. For more information see IETF draftdraft-brezak-spnego-http-04.txt..TP.B CURLAUTH_NTLMHTTP NTLM authentication. A proprietary protocol invented and used byMicrosoft. It uses a challenge-response and hash concept similar to Digest toprevent the password from being evesdropped..TP.B CURLAUTH_ANYThis is a convenience macro that sets all bits and thus makes libcurl pick anyit finds suitable. libcurl will automaticly select the one it finds mostsecure..TP.B CURLAUTH_ANYSAFEThis is a convenience macro that sets all bits except Basic and thus makeslibcurl pick any it finds suitable. libcurl will automaticly select the one itfinds most secure..RE.TP.B CURLOPT_PROXYAUTHPass a long as parameter, which is set to a bitmask, to tell libcurl whatauthentication method(s) you want it to use for your proxy authentication.  Ifmore than one bit is set, libcurl will first query the site to see whatauthentication methods it supports and then pick the best one you allow it touse. Note that for some methods, this will induce an extra networkround-trip. Set the actual name and password with the\fICURLOPT_PROXYUSERPWD\fP option. The bitmask can be constructed by or'ingtogether the bits listed above for the \fICURLOPT_HTTPAUTH\fP option. As ofthis writing, only Basic and NTLM work. (Added in 7.10.7).PP.SH HTTP OPTIONS.TP 0.4i.B CURLOPT_ENCODINGSets the contents of the Accept-Encoding: header sent in an HTTPrequest, and enables decoding of a response when a Content-Encoding:header is received.  Three encodings are supported: \fIidentity\fP,which does nothing, \fIdeflate\fP which requests the server tocompress its response using the zlib algorithm, and \fIgzip\fP whichrequests the gzip algorithm.  If a zero-length string is set, then anAccept-Encoding: header containing all supported encodings is sent.This is a request, not an order; the server may or may not do it.  Thisoption must be set (to any non-NULL value) or else any unsolicitedencoding done by the server is ignored. See the special filelib/README.encoding for details..TP.B CURLOPT_FOLLOWLOCATIONA non-zero parameter tells the library to follow any Location: header that theserver sends as part of a HTTP header.\fBNOTE:\fP this means that the library will re-send the same request on thenew location and follow new Location: headers all the way until no more suchheaders are returned. \fICURLOPT_MAXREDIRS\fP can be used to limit the numberof redirects libcurl will follow..TP.B CURLOPT_UNRESTRICTED_AUTHA non-zero parameter tells the library it can continue to send authentication(user+password) when following locations, even when hostname changed. Notethat this is meaningful only when setting \fICURLOPT_FOLLOWLOCATION\fP..TP.B CURLOPT_MAXREDIRSPass a long. The set number will be the redirection limit. If that manyredirections have been followed, the next redirect will cause an error(\fICURLE_TOO_MANY_REDIRECTS\fP). This option only makes sense if the\fICURLOPT_FOLLOWLOCATION\fP is used at the same time..TP.B CURLOPT_PUTA non-zero parameter tells the library to use HTTP PUT to transfer data. Thedata should be set with CURLOPT_READDATA and CURLOPT_INFILESIZE..TP.B CURLOPT_POSTA non-zero parameter tells the library to do a regular HTTP post. This is anormal application/x-www-form-urlencoded kind, which is the most commonly usedone by HTML forms. See the CURLOPT_POSTFIELDS option for how to specify thedata to post and CURLOPT_POSTFIELDSIZE in how to set the data size. Startingwith libcurl 7.8, this option is obsolete. Using the CURLOPT_POSTFIELDS optionwill imply this option..TP.B CURLOPT_POSTFIELDSPass a char * as parameter, which should be the full data to post in a HTTPpost operation. You need to make sure that the data is formatted the way youwant the server to receive it. libcurl will not convert or encode it foryou. Most web servers will assume this data to be url-encoded. Take note.This POST is a normal application/x-www-form-urlencoded kind (and libcurl willset that Content-Type by default when this option is used), which is the mostcommonly used one by HTML forms. See also the CURLOPT_POST. UsingCURLOPT_POSTFIELDS implies CURLOPT_POST.\fBNote:\fP to make multipart/formdata posts (aka rfc1867-posts), check outthe \fICURLOPT_HTTPPOST\fP option..TP.B CURLOPT_POSTFIELDSIZEIf you want to post data to the server without letting libcurl do a strlen()to measure the data size, this option must be used. When this option is usedyou can post fully binary data, which otherwise is likely to fail. If thissize is set to zero, the library will use strlen() to get the size..TP.B CURLOPT_HTTPPOSTTells libcurl you want a multipart/formdata HTTP POST to be made and youinstruct what data to pass on to the server.  Pass a pointer to a linked listof HTTP post structs as parameter.  The linked list should be a fully validlist of 'struct HttpPost' structs properly filled in. The best and mostelegant way to do this, is to use \fIcurl_formadd(3)\fP as documented. Thedata in this list must remain intact until you close this curl handle againwith \fIcurl_easy_cleanup(3)\fP..TP.B CURLOPT_REFERERPass a pointer to a zero terminated string as parameter. It will be used toset the Referer: header in the http request sent to the remote server. Thiscan be used to fool servers or scripts. You can also set any custom headerwith \fICURLOPT_HTTPHEADER\fP..TP.B CURLOPT_USERAGENTPass a pointer to a zero terminated string as parameter. It will be used toset the User-Agent: header in the http request sent to the remote server. Thiscan be used to fool servers or scripts. You can also set any custom headerwith \fICURLOPT_HTTPHEADER\fP..TP.B CURLOPT_HTTPHEADERPass a pointer to a linked list of HTTP headers to pass to the server in yourHTTP request. The linked list should be a fully valid list of \fBstructcurl_slist\fP structs properly filled in. Use \fIcurl_slist_append(3)\fP tocreate the list and \fIcurl_slist_free_all(3)\fP to clean up an entirelist. If you add a header that is otherwise generated and used by libcurlinternally, your added one will be used instead. If you add a header with nocontents as in 'Accept:' (no data on the right side of the colon), theinternally used header will get disabled. Thus, using this option you can addnew headers, replace internal headers and remove internal headers. Theheaders included in the linked list must not be CRLF-terminated, becausecurl adds CRLF after each header item. Failure to comply with this willresult in strange bugs because the server will most likely ignore partof the headers you specified.The first line in a request (usually containing a GET or POST) is not a headerand cannot be replaced using this option. Only the lines following therequest-line are headers.\fBNOTE:\fPThe most commonly replaced headers have "shortcuts" in the optionsCURLOPT_COOKIE, CURLOPT_USERAGENT and CURLOPT_REFERER..TP.B CURLOPT_HTTP200ALIASESPass a pointer to a linked list of aliases to be treated as valid HTTP 200responses.  Some servers respond with a custom header response line.  Forexample, IceCast servers respond with "ICY 200 OK".  By including this stringin your list of aliases, the response will be treated as a valid HTTP headerline such as "HTTP/1.0 200 OK". (Added in 7.10.3)The linked list should be a fully valid list of struct curl_slist structs, andbe properly filled in.  Use \fIcurl_slist_append(3)\fP to create the list and\fIcurl_slist_free_all(3)\fP to clean up an entire list.\fBNOTE:\fPThe alias itself is not parsed for any version strings.  So if youralias is "MYHTTP/9.9", Libcurl will not treat the server as responding withHTTP version 9.9.  Instead Libcurl will use the value set by option\fICURLOPT_HTTP_VERSION\fP..TP.B CURLOPT_COOKIEPass a pointer to a zero terminated string as parameter. It will be used toset a cookie in the http request. The format of the string should beNAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookieshould contain.If you need to set mulitple cookies, you need to set them all using a singleoption and thus you need to concat them all in one single string. Set multiplecookies in one string like this: "name1=content1; name2=content2;" etc.Using this option multiple times will only make the latest string override thepreviously ones..TP.B CURLOPT_COOKIEFILEPass a pointer to a zero terminated string as parameter. It should contain thename of your file holding cookie data to read. The cookie data may be inNetscape / Mozilla cookie data format or just regular HTTP-style headersdumped to a file.Given an empty or non-existing file, this option will enable cookies for thiscurl handle, making it understand and parse received cookies and then usematching cookies in future request..TP.B CURLOPT_COOKIEJARPass a file name as char *, zero terminated. This will make libcurl write allinternally known cookies to the specified file when \fIcurl_easy_cleanup(3)\fPis called. If no cookies are known, no file will be created. Specify "-" toinstead have the cookies written to stdout. Using this option also enablescookies for this session, so if you for example follow a location it will makematching cookies get sent accordingly..B NOTEIf the cookie jar file can't be created or written to (when thecurl_easy_cleanup() is called), libcurl will not and cannot report an errorfor this. Using CURLOPT_VERBOSE or CURLOPT_DEBUGFUNCTION will get a warning todisplay, but that is the only visible feedback you get about this possiblylethal situation..TP.B CURLOPT_TIMECONDITIONPass a long as parameter. This defines how the CURLOPT_TIMEVALUE time value istreated. You can set this parameter to TIMECOND_IFMODSINCE orTIMECOND_IFUNMODSINCE. This is a HTTP-only feature. (TBD).TP.B CURLOPT_TIMEVALUEPass a long as parameter. This should be the time in seconds since 1 jan 1970,and the time will be used in a condition as specified withCURLOPT_TIMECONDITION..TP.B CURLOPT_HTTPGETPass a long. If the long is non-zero, this forces the HTTP request to get backto GET. Only really usable if POST, PUT or a custom request have been usedpreviously using the same curl handle..TP.B CURLOPT_HTTP_VERSIONPass a long, set to one of the values described below. They force libcurl touse the specific HTTP versions. This is not sensible to do unless you have agood reason..RS.TP 5.B CURL_HTTP_VERSION_NONEWe don't care about what version the library uses. libcurl will use whateverit thinks fit..TP.B CURL_HTTP_VERSION_1_0Enforce HTTP 1.0 requests..TP.B CURL_HTTP_VERSION_1_1Enforce HTTP 1.1 requests..RE.PP.SH FTP OPTIONS.TP 0.4i.B CURLOPT_FTPPORTPass a pointer to a zero terminated string as parameter. It will be used toget the IP address to use for the ftp PORT instruction. The PORT instructiontells the remote server to connect to our specified IP address. The string maybe a plain IP address, a host name, an network interface name (under Unix) orjust a '-' letter to let the library use your systems default IPaddress. Default FTP operations are passive, and thus won't use PORT.You disable PORT again and go back to using the passive version by settingthis option to NULL..TP.B CURLOPT_QUOTEPass a pointer to a linked list of FTP commands to pass to the server prior toyour ftp request. This will be done before any other FTP commands are issued(even before the CWD command). The linked list should be a fully valid list of'struct curl_slist' structs properly filled in. Use \fIcurl_slist_append(3)\fPto append strings (commands) to the list, and clear the entire list afterwardswith \fIcurl_slist_free_all(3)\fP. Disable this operation again by setting aNULL to this option..TP.B CURLOPT_POSTQUOTEPass a pointer to a linked list of FTP commands to pass to the server afteryour ftp transfer request. The linked list should be a fully valid list ofstruct curl_slist structs properly filled in as described for\fICURLOPT_QUOTE\fP. Disable this operation again by setting a NULL to thisoption..TP.B CURLOPT_PREQUOTEPass a pointer to a linked list of FTP commands to pass to the server afterthe transfer type is set. The linked list should be a fully valid list ofstruct curl_slist structs properly filled in as described for\fICURLOPT_QUOTE\fP. Disable this operation again by setting a NULL to thisoption..TP.B CURLOPT_FTPLISTONLYA non-zero parameter tells the library to just list the names of an ftp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -