PHP uses the cURl library function to obtain detailed webpage information

Source: Internet
Author: User
Recently, I used the cURl library function in a small project. I found some information from the Internet and summarized it by referring to a foreign Blog and official manual. Functionget_web_page ($ url) {$ options = array (CURLOPT_RETURNTRANSFER = true, // returnwebpage returns the webpage CURLOPT_H

Recently, I used the cURl library function in a small project. I found some information from the Internet and summarized it by referring to a foreign Blog and official manual.
Function get_web_page ($ url)
{
$ Options = array (
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // no return information
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // Set UserAgent
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect connection timeout
CURLOPT_TIMEOUT => 120, // timeout on response timeout
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
);
$ Ch = curl_init ($ url );
Curl_setopt_array ($ ch, $ options );
$ Content = curl_exec ($ ch );
$ Err = curl_errno ($ ch );
$ Errmsg = curl_error ($ ch );
$ Header = curl_getinfo ($ ch );
Curl_close ($ ch );
$ Header ['errno'] = $ err;
$ Header ['errmsg '] = $ errmsg;
$ Header ['content'] = $ content;
Return $ header;
}
Original English:
Http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl
 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.