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
Release: 2016-07-21 15:12:03
Original
1039 people have browsed it

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,...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template