Home > Backend Development > PHP Tutorial > PHP obtains detailed explanation of web pages through cURl library function_PHP tutorial

PHP obtains detailed explanation of web pages through cURl library function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:38:44
Original
818 people have browsed it

I recently worked on a small project that used the cURl library function. I found some information from the Internet, referred to a foreign blog and official manual, and summarized it.
function get_web_page( $url )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page Return to web page
CURLOPT_HEADER => false, // Do not return header 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 reply 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 text:
http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486456.htmlTechArticleI recently did a small project using the cURl library function. I found some information from the Internet and referred to a foreign blog and official website. Manual, to summarize. function get_web_page( $url ) { $options = array( CU...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template