Home >Backend Development >PHP Tutorial >File_get_contents cannot obtain the solution to the web page content_PHP tutorial

File_get_contents cannot obtain the solution to the web page content_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:12:031038browse

Copy code The code is as follows:

$url = "http://jb51.net /index.html";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//You need to add the following two lines to the webpage that requires user detection
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
? >

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326749.htmlTechArticleCopy the code as follows: ?php $url = "http://jb51.net/index.html"; $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,...
Statement:
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