国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
curl usage at the command line
Command parameters
Instances
Use of curl under PHP scripts
Install cURL Library
ordinary grabbing webpage instances
Home Backend Development PHP Tutorial Application of CURL and PHP-CLI [CURL]

Application of CURL and PHP-CLI [CURL]

Aug 08, 2016 am 09:24 AM

curl is an extremely powerful HTTP transfer tool that supports file upload and download;

curl usage at the command line

Command parameters
-a/--append?上傳文件時(shí),附加到目標(biāo)文件
-A/--user-agent設(shè)置用戶代理發(fā)送給服務(wù)器
-?anyauth???可以使用“任何”身份驗(yàn)證方法
-b/--cookiecookie字符串或文件讀取位置
-?basic?使用HTTP基本驗(yàn)證
-B/--use-ascii?使用ASCII?/文本傳輸
-c/--cookie-jar操作結(jié)束后把cookie寫入到這個(gè)文件中
-C/--continue-at斷點(diǎn)續(xù)轉(zhuǎn)
-d/--dataHTTP?POST方式傳送數(shù)據(jù)
--data-ascii以ascii的方式post數(shù)據(jù)
--data-binary以二進(jìn)制的方式post數(shù)據(jù)
--negotiate?????使用HTTP身份驗(yàn)證
--digest????????使用數(shù)字身份驗(yàn)證
--disable-eprt??禁止使用EPRT或LPRT
--disable-epsv??禁止使用EPSV
-D/--dump-header把header信息寫入到該文件中
--egd-file為隨機(jī)數(shù)據(jù)(SSL)設(shè)置EGD?socket路徑
--tcp-nodelay???使用TCP_NODELAY選項(xiàng)
-e/--referer?來源網(wǎng)址
-E/--cert客戶端證書文件和密碼?(SSL)
--cert-type證書文件類型?(DER/PEM/ENG)?(SSL)
--key私鑰文件名?(SSL)
--key-type私鑰文件類型?(DER/PEM/ENG)?(SSL)
--pass私鑰密碼?(SSL)
--engine加密引擎使用?(SSL).?"--engine?list"?for?list
--cacertCA證書?(SSL)
--capathCA目錄?(made?using?c_rehash)?to?verify?peer?against?(SSL)
--ciphersSSL密碼
--compressed????要求返回是壓縮的形勢?(using?deflate?or?gzip)
--connect-timeout設(shè)置最大請求時(shí)間
--create-dirs???建立本地目錄的目錄層次結(jié)構(gòu)
--crlf??????????上傳是把LF轉(zhuǎn)變成CRLF
-f/--fail??????????連接失敗時(shí)不顯示http錯(cuò)誤
--ftp-create-dirs?如果遠(yuǎn)程目錄不存在,創(chuàng)建遠(yuǎn)程目錄
--ftp-method?[multicwd/nocwd/singlecwd]?控制CWD的使用
--ftp-pasv??????使用?PASV/EPSV?代替端口
--ftp-skip-pasv-ip?使用PASV的時(shí)候,忽略該IP地址
--ftp-ssl???????嘗試用?SSL/TLS?來進(jìn)行ftp數(shù)據(jù)傳輸
--ftp-ssl-reqd??要求用?SSL/TLS?來進(jìn)行ftp數(shù)據(jù)傳輸
-F/--form模擬http表單提交數(shù)據(jù)
-form-string模擬http表單提交數(shù)據(jù)
-g/--globoff?禁用網(wǎng)址序列和范圍使用{}和[]
-G/--get?以get的方式來發(fā)送數(shù)據(jù)
-h/--help?幫助
-H/--header自定義頭信息傳遞給服務(wù)器
--ignore-content-length??忽略的HTTP頭信息的長度
-i/--include?輸出時(shí)包括protocol頭信息
-I/--head??只顯示文檔信息
從文件中讀取-j/--junk-session-cookies忽略會(huì)話Cookie
-?界面指定網(wǎng)絡(luò)接口/地址使用
-?krb4?啟用與指定的安全級別krb4
-j/--junk-session-cookies?讀取文件進(jìn)忽略session?cookie
--interface使用指定網(wǎng)絡(luò)接口/地址
--krb4使用指定安全級別的krb4
-k/--insecure?允許不使用證書到SSL站點(diǎn)
-K/--config??指定的配置文件讀取
-l/--list-only?列出ftp目錄下的文件名稱
--limit-rate設(shè)置傳輸速度
--local-port強(qiáng)制使用本地端口號
-m/--max-time設(shè)置最大傳輸時(shí)間
--max-redirs設(shè)置最大讀取的目錄數(shù)
--max-filesize設(shè)置最大下載的文件總量
-M/--manual??顯示全手動(dòng)
-n/--netrc?從netrc文件中讀取用戶名和密碼
--netrc-optional?使用?.netrc?或者?URL來覆蓋-n
--ntlm??????????使用?HTTP?NTLM?身份驗(yàn)證
-N/--no-buffer?禁用緩沖輸出
-o/--output?把輸出寫到該文件中
-O/--remote-name?把輸出寫到該文件中,保留遠(yuǎn)程文件的文件名
-p/--proxytunnel???使用HTTP代理
--proxy-anyauth?選擇任一代理身份驗(yàn)證方法
--proxy-basic???在代理上使用基本身份驗(yàn)證
--proxy-digest??在代理上使用數(shù)字身份驗(yàn)證
--proxy-ntlm????在代理上使用ntlm身份驗(yàn)證
-P/--ftp-port使用端口地址,而不是使用PASV
-Q/--quote文件傳輸前,發(fā)送命令到服務(wù)器
-r/--range檢索來自HTTP/1.1或FTP服務(wù)器字節(jié)范圍
--range-file?讀?。⊿SL)的隨機(jī)文件
-R/--remote-time???在本地生成文件時(shí),保留遠(yuǎn)程文件時(shí)間
--retry傳輸出現(xiàn)問題時(shí),重試的次數(shù)
--retry-delay傳輸出現(xiàn)問題時(shí),設(shè)置重試間隔時(shí)間
--retry-max-time傳輸出現(xiàn)問題時(shí),設(shè)置最大重試時(shí)間
-s/--silent靜音模式。不輸出任何東西
-S/--show-error???顯示錯(cuò)誤
--socks4用socks4代理給定主機(jī)和端口
--socks5用socks5代理給定主機(jī)和端口
--stderr-t/--telnet-optionTelnet選項(xiàng)設(shè)置
--trace對指定文件進(jìn)行debug
--trace-asciiLike?--跟蹤但沒有hex輸出
--trace-time????跟蹤/詳細(xì)輸出時(shí),添加時(shí)間戳
-T/--upload-file上傳文件
--urlSpet?URL?to?work?with
-u/--user設(shè)置服務(wù)器的用戶和密碼
-U/--proxy-user設(shè)置代理用戶名和密碼
-v/--verbose
-V/--version?顯示版本信息
-w/--write-out?[format]什么輸出完成后
-x/--proxy在給定的端口上使用HTTP代理
-X/--request指定什么命令
-y/--speed-time?放棄限速所要的時(shí)間。默認(rèn)為30
-Y/--speed-limit?停止傳輸速度的限制,速度時(shí)間'秒'
-z/--time-cond??傳送時(shí)間設(shè)置
-0/--http1.0??使用HTTP?1.0
-1/--tlsv1??使用TLSv1(SSL)
-2/--sslv2?使用SSLv2的(SSL)
-3/--sslv3?????????使用的SSLv3(SSL)
--3p-quote??????like?-Q?for?the?source?URL?for?3rd?party?transfer
--3p-url????????使用url,進(jìn)行第三方傳送
--3p-user???????使用用戶名和密碼,進(jìn)行第三方傳送
-4/--ipv4???使用IP4
-6/--ipv6???使用IP6
-#/--progress-bar?用進(jìn)度條顯示當(dāng)前的傳送狀態(tài)
Instances

Catch page content into a file

curl?-o?home.html??http://www.pinlehuo.com?
$?-o/--output?把輸出寫到該文件中

#?或者?↓↓

$?curl?http://www.linuxidc.com?>?page.html

To capture a specific file, use -O (capital), and the following URL must be specific to a certain file, otherwise it will not be captured. We can also use regular expressions to capture things, but the file name still has to be specific

$?curl?-O?www.pinlehuo.com/d/file/admin/2015/05/5551bf06428ec.jpg

$?curl?-O?http://www.codesky.net/wp-content/uploads/2010/[0-9][0-9]/aaaaa.jpg

Simulate form information, simulate login, save cookie information

#?-D/--dump-header把header信息寫入到該文件中
$?curl?-c?./cookie_c.txt?-F?log=aaaa?-F?pwd=******?http://www.codesky.net/wp-login.php?(沒試過~)

View response header information

curl?-I?http://www.sunrisecorp.net/

Simulate form information, simulate login, save header information

curl?-D?./cookie_D.txt?-F?log=aaaa?-F?pwd=******?http://www.codesky.net/wp-login.php
#?-c(小寫)產(chǎn)生的cookie和-D里面的cookie是不一樣的。

Use cookie files

curl?-b?./cookie_c.txt??http://www.codesky.net/wp-admin

Resume breakpoints, -C (capital)

curl?-C?-O?http://www.codesky.net/wp-content/uploads/2010/09/compare_varnish.jpg

Transfer data, it is best to use the login page to test, because after you pass the value, curl will capture the data, and you can see that you passed Is it successful?

curl?-d?log=aaaa??http://www.codesky.net/wp-login.php

Forge the source address. Some websites will judge and request the source address

curl?-e?http://localhost?http://www.codesky.net/wp-login.php

When we often use curl to get other people’s things, they will block your IP. At this time, we You can use a proxy

curl?-x?24.10.28.84:32779?-o?home.html?http://www.codesky.net

For larger things, we can download in sections

[root@krlcgcms01?mytest]#?curl?-r?0-100?-o?img.part1?http://www.codesky.net/wp-
content/uploads/2010/09/compare_varnish.jpg
?%?Total????%?Received?%?Xferd??Average?Speed???Time????Time?????Time??Current
?Dload??Upload???Total???Spent????Left??Speed
100???101??100???101????0?????0????105??????0?--:--:--?--:--:--?--:--:--?????0
[root@krlcgcms01?mytest]#?curl?-r?100-200?-o?img.part2?http://www.codesky.net/wp-
content/uploads/2010/09/compare_varnish.jpg
?%?Total????%?Received?%?Xferd??Average?Speed???Time????Time?????Time??Current
?Dload??Upload???Total???Spent????Left??Speed
100???101??100???101????0?????0?????57??????0??0:00:01??0:00:01?--:--:--?????0
[root@krlcgcms01?mytest]#?curl?-r?200-?-o?img.part3?http://www.codesky.net/wp-
content/uploads/2010/09/compare_varnish.jpg
?%?Total????%?Received?%?Xferd??Average?Speed???Time????Time?????Time??Current
?Dload??Upload???Total???Spent????Left??Speed
100??104k??100??104k????0?????0??52793??????0??0:00:02??0:00:02?--:--:--?88961
[root@krlcgcms01?mytest]#?ls?|grep?part?|?xargs?du?-sh
4.0K????one.part1
112K????three.part3
4.0K????two.part2
用的時(shí)候,把他們cat一下就OK了,cat?img.part*?>img.jpg

Display download progress information

[root@krlcgcms01?mytest]#?curl?-#?-O??http://www.codesky.net/wp-content/uploads/2010/09/compare_varnish.jpg
########################################################################?100.0%

Download files through ftp

[zhangy@BlackGhost?~]$?curl?-u?用戶名:密碼?-O?http://www.codesky.net/demo/curtain/bbstudy_files/style.css
?%?Total????%?Received?%?Xferd??Average?Speed???Time????Time?????Time??Current
?Dload??Upload???Total???Spent????Left??Speed
101??1934??101??1934????0?????0???3184??????0?--:--:--?--:--:--?--:--:--??7136
或者用下面的方式
[zhangy@BlackGhost?~]$?curl?-O?ftp://用戶名:密碼@ip:port/demo/curtain/bbstudy_files/style.css

Upload through ftp

[zhangy@BlackGhost?~]$?curl?-T?test.sql?ftp://用戶名:密碼@ip:port/demo/curtain/bbstudy_files/

Use of curl under PHP scripts

Install cURL Library

WAMP environment
Open the following 2 files respectively:
wampbinphp(your php version)php.ini
wampbinApache(your apache version)binphp.ini
Search for extension=php_curl.dll, and then delete the previous symbols;
Restart WAMP That’s it.
//↑↑Follow the above operations first, if not, then refer to the following two;
Note: If it is a 64-bit system, you also need to visit http://www.anindya.com/ to download the corresponding version of 64-bit php Compressed package, after decompression, overwrite the php_curl.dll file in the ext directory with the php_curl.dll file in the ext directory of wamp php corresponding version wampbinphpphp5.4.12, and then restart WAMP
Reference website: http://blog.csdn.net/ewili/ article/details/9008493

window
1.php.ini remove the semicolon in front of extension=php_curl.dll;
2.php_curl.dll,libeay32.dll,ssleay32.dll and copy them to %windir%/system32

linux
If php has been compiled in the system, new extensions need to be added later. One way is to completely recompile PHP, and the other way is to compile the extension library separately and extend it in the form of extension. The following is an example of installing the curl extension:
./configure
make
php requires that the curl directory must have include and lib directories, and there must be two files easy.h and curl.h under include, and libcurl.a must be under lib. . After compilation, the files in include exist, but not in the lib directory. It was originally generated in the lib/.libs directory, so you need to copy it to the lib directory

2. Enter the source code directory where the original php was installed,
cd ext
cd curl
phpize
./configure --with-curl=DIR
make
The curl.so file will be generated under PHPDIR/ext/curl/moudles/. U Curl function library

curl_close?—?關(guān)閉一個(gè)curl會(huì)話
curl_copy_handle?—?拷貝一個(gè)curl連接資源的所有內(nèi)容和參數(shù)
curl_errno?—?返回一個(gè)包含當(dāng)前會(huì)話錯(cuò)誤信息的數(shù)字編號
curl_error?—?返回一個(gè)包含當(dāng)前會(huì)話錯(cuò)誤信息的字符串
curl_exec?—?執(zhí)行一個(gè)curl會(huì)話
curl_getinfo?—?獲取一個(gè)curl連接資源句柄的信息
curl_init?—?初始化一個(gè)curl會(huì)話
curl_multi_add_handle?—?向curl批處理會(huì)話中添加單獨(dú)的curl句柄資源
curl_multi_close?—?關(guān)閉一個(gè)批處理句柄資源
curl_multi_exec?—?解析一個(gè)curl批處理句柄
curl_multi_getcontent?—?返回獲取的輸出的文本流
curl_multi_info_read?—?獲取當(dāng)前解析的curl的相關(guān)傳輸信息
curl_multi_init?—?初始化一個(gè)curl批處理句柄資源
curl_multi_remove_handle?—?移除curl批處理句柄資源中的某個(gè)句柄資源
curl_multi_select?—?Get?all?the?sockets?associated?with?the?cURL?extension,?which?can?then?be?"selected"
curl_setopt_array?—?以數(shù)組的形式為一個(gè)curl設(shè)置會(huì)話參數(shù)
curl_setopt?—?為一個(gè)curl設(shè)置會(huì)話參數(shù)
參考網(wǎng)址:http://blog.csdn.net/superbirds/article/details/7532277:?curl_setopt?會(huì)話參數(shù)詳解
參考網(wǎng)址:http://www.zhibotie.net/space-1-do-blog-id-71.html

curl_version?—?獲取curl相關(guān)的版本信息
curl_init()函數(shù)的作用初始化一個(gè)curl會(huì)話,curl_init()函數(shù)唯一的一個(gè)參數(shù)是可選的,表示一個(gè)url地址。
curl_exec()函數(shù)的作用是執(zhí)行一個(gè)curl會(huì)話,唯一的參數(shù)是curl_init()函數(shù)返回的句柄。
curl_close()函數(shù)的作用是關(guān)閉一個(gè)curl會(huì)話,唯一的參數(shù)是curl_init()函數(shù)返回的句柄。
ordinary grabbing webpage instances
//?1.?初始化
$ch?=?curl_init();
//$ch?=?curl_init("http://www.baidu.com/");

//?2.?設(shè)置選項(xiàng),包括URL
curl_setopt($ch,?CURLOPT_URL,?"http://www.baidu.com/");//CURLOPT_URL:?這是你想用PHP取回的URL地址。
你也可以在用curl_init()函數(shù)初始化時(shí)設(shè)置這個(gè)選項(xiàng)

curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?1);//設(shè)定是否輸出頁面內(nèi)容,這里為0的話,后面就不用echo,
就直接把curl抓回來的內(nèi)容輸出;
curl_setopt($ch,?CURLOPT_HEADER,?0);//設(shè)定是否顯示頭信息,為1的時(shí)候,就會(huì)把響應(yīng)頭信息也給一并輸出

//?3.?執(zhí)行并獲取HTML文檔內(nèi)容
$output?=?curl_exec($ch);
//echo?$output;//輸出抓回來的網(wǎng)頁;如果curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?0),就不需要此句;

//?4.?釋放curl句柄
curl_close($ch);

judge errors and output errors on the basis of capturing. The application of PHP-CLI [CURL] includes various aspects. For more related content, please pay attention to the PHP Chinese website (m.miracleart.cn)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to realize the mutual conversion between CURL and python requests in python How to realize the mutual conversion between CURL and python requests in python May 03, 2023 pm 12:49 PM

Both curl and Pythonrequests are powerful tools for sending HTTP requests. While curl is a command-line tool that allows you to send requests directly from the terminal, Python's requests library provides a more programmatic way to send requests from Python code. The basic syntax for converting curl to Pythonrequestscurl command is as follows: curl[OPTIONS]URL When converting curl command to Python request, we need to convert the options and URL into Python code. Here is an example curlPOST command: curl-XPOST https://example.com/api

Tutorial on updating curl version under Linux! Tutorial on updating curl version under Linux! Mar 07, 2024 am 08:30 AM

To update the curl version under Linux, you can follow the steps below: Check the current curl version: First, you need to determine the curl version installed in the current system. Open a terminal and execute the following command: curl --version This command will display the current curl version information. Confirm available curl version: Before updating curl, you need to confirm the latest version available. You can visit curl's official website (curl.haxx.se) or related software sources to find the latest version of curl. Download the curl source code: Using curl or a browser, download the source code file for the curl version of your choice (usually .tar.gz or .tar.bz2

PHP8.1 released: Introducing curl for concurrent processing of multiple requests PHP8.1 released: Introducing curl for concurrent processing of multiple requests Jul 08, 2023 pm 09:13 PM

PHP8.1 released: Introducing curl for concurrent processing of multiple requests. Recently, PHP officially released the latest version of PHP8.1, which introduced an important feature: curl for concurrent processing of multiple requests. This new feature provides developers with a more efficient and flexible way to handle multiple HTTP requests, greatly improving performance and user experience. In previous versions, handling multiple requests often required creating multiple curl resources and using loops to send and receive data respectively. Although this method can achieve the purpose

From start to finish: How to use php extension cURL to make HTTP requests From start to finish: How to use php extension cURL to make HTTP requests Jul 29, 2023 pm 05:07 PM

From start to finish: How to use php extension cURL for HTTP requests Introduction: In web development, it is often necessary to communicate with third-party APIs or other remote servers. Using cURL to make HTTP requests is a common and powerful way. This article will introduce how to use PHP to extend cURL to perform HTTP requests, and provide some practical code examples. 1. Preparation First, make sure that php has the cURL extension installed. You can execute php-m|grepcurl on the command line to check

How to handle 301 redirection of web pages in PHP Curl? How to handle 301 redirection of web pages in PHP Curl? Mar 08, 2024 am 11:36 AM

How to handle 301 redirection of web pages in PHPCurl? When using PHPCurl to send network requests, you will often encounter a 301 status code returned by the web page, indicating that the page has been permanently redirected. In order to handle this situation correctly, we need to add some specific options and processing logic to the Curl request. The following will introduce in detail how to handle 301 redirection of web pages in PHPCurl, and provide specific code examples. 301 redirect processing principle 301 redirect means that the server returns a 30

what is linux curl what is linux curl Apr 20, 2023 pm 05:05 PM

In Linux, curl is a very practical tool for transferring data to and from the server. It is a file transfer tool that uses URL rules to work under the command line; it supports file upload and download, and is a comprehensive transfer tool. . Curl provides a lot of very useful functions, including proxy access, user authentication, ftp upload and download, HTTP POST, SSL connection, cookie support, breakpoint resume and so on.

How to set cookies in php curl How to set cookies in php curl Sep 26, 2021 am 09:27 AM

How to set cookies in php curl: 1. Create a PHP sample file; 2. Set cURL transmission options through the "curl_setopt" function; 3. Pass the cookie in CURL.

Why doesn't PHP7.3 support curl? How to deal with it? Why doesn't PHP7.3 support curl? How to deal with it? Mar 24, 2023 pm 05:09 PM

PHP is a well-known Internet programming language that is widely used in web development due to its powerful functions and ease of use, and is widely used in websites around the world. However, in PHP7.3, we found that some common tools such as curl cannot be used properly. So, why doesn't PHP7.3 support curl? What's the solution? This article discusses this issue in detail.

See all articles