One, what is curl?CURL is a tool that uses URL syntax to transfer files and data, and supports many protocols, such as HTTP, FTP, Telnet, and so on. Best of all, PHP also supports the CURL library. Using the PHP Curl Library, you can easily and
Curl Libraries in PHP (Client URL library function)
curl_close-closing a Curl session
curl_copy_handle-Copy all the contents and parameters of a Curl connection resource
curl_errno-returns a numeric number that contains the current session error
Curl function library in PHP (Client URL library function)
Curl_close-closes a Curl session
curl_copy_handle-copies all the contents and parameters of a Curl connection resource
curl_errno-returns a numeric number containing the current session
First, write a simple crawl page function
Copy Code code as follows:
function Getsources ($URL, $User _agent= ', $Referer _url= ')//crawl a specified page
{
$URL page address that needs to be crawled
$User _agent need to return
At first Curl was designed as a command-line tool, and fortunately, PHP also supports curl. By Curl This tool, we can freely send HTTP requests to a URL to obtain or submit data in a PHP program, and support many other protocols, such as
Download a single file and print the output to the standard output (stdout) by default.
curl http://www.centos.org
Use the-O/-O option to save the downloaded file to the specified file:-O: saves the file as the file name specified in the command
In PHP, the Curl function has a set of related functions, it is a very good function, we often use it to imitate a variety of login and collection work, let me introduce you to the Curl function get started.
About Curl
Curl is a tool that uses URL
curl_setopt--Sets an option for the curl callDescribe BOOL curl_setopt (INT-ch, string option, mixed value) The curl_setopt () function sets the option for a curl session. The option parameter is the setting you want, and value is the values
download a single file and print the output to the standard output (STDOUT) in Curl HTTP by default://www.centos.orgSave the downloaded file to the specified file via the-o/-o option:-o: Save the file as the file name specified on the command line-O:
1.CURL is an open source file Transfer tool that works with URL syntax in the command line mode.2. It is widely used in UNIX and many Linux distributions. And there are DOS and Win32, Win64 under the transplant version number.3. It supports very
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.