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
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
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
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
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
PHP-Curl used (to) to load from: http://lelong.iteye.com/blog/538645
This article describes the php_curl library and how to better use php_curl.
Introduction
You may encounter the following problem in your PHP script code: how can I get
Original (English) address: http://www.phpit.net/article/using-curl-php copyright notice: Attribution-Non-commercial use-No deduction 2.0
Summary:
In this article, we mainly explain the knowledge of Php_curl library and teach you how to use Php_
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.