As a PHP developer or a person who frequently accesses the PHP source code, CURL is very familiar with it. But do you really know CURL? Don't you just know what it is for, or you just know it. In fact, the CURL component is often seen and widely used in many places. For example, capture a page and submit it to the page
As a PHP developer or a person who frequently accesses the PHP source code, CURL is very familiar with it. But do you really know CURL? Don't you just know what it is for, or you just know it. In fact, the CURL component is often seen and widely used in many places. For example, capture a page and submit it to the page
As a PHP developer or a person who frequently accesses the PHP source code, CURL is very familiar with it. But do you really know CURL? Don't you just know what it is for, or you just know it. In fact, the CURL component is often seen and widely used in many places. For example, capture a page and submit data to the page. It can be said that CURL is the same as other popular applications and must be mastered. Next, let's look at an instance that uses CURL to capture pages:
Function curl_download ($ Url) {// to prevent errors, check whether the CURL component if (! Function_exists ('curl _ init ') {die (Sorry, the curl component is not installed! ');} // Yes. Now that we have installed a new handle $ ch = curl_init (); // you can set the curl_setopt ($ ch, CURLOPT_URL, $ Url) address to be crawled ); // create an http Referer. Some websites will determine the request route. We can forge curl_setopt ($ ch, CURLOPT_REFERER, "Callback); // set the user proxy curl_setopt ($ ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); // do you want to include the header ID (0 = yes, 1 = no) curl_setopt ($ ch, CURLOPT_HEADER, 0 ); // determine whether to return or print the data (true = return, false = print) curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); // The number of timeout seconds curl_setopt ($ ch, CURLOPT_TIMEOUT, 10); // start capturing and return the corresponding data $ output = curl_exec ($ ch); // close the connection curl_close ($ ch); return $ output ;}