当file_get_contents获取不到网页内容时,以下方法可使用
2013-03-07 09:59
555 查看
<?php
$url = "http://maoshow.com/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);
//在需要用户检测的网页里需要增加下面两行
//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;
?>
$url = "http://maoshow.com/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);
//在需要用户检测的网页里需要增加下面两行
//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;
?>
相关文章推荐
- 当file_get_contents获取不到网页内容时,以下方法可使用
- file_get_contents获取不到网页内容的解决方法
- file_get_contents获取不到网页内容的解决方法
- PHP下通过file_get_contents\curl的方法实现获取远程网页内容(别忘了还有PhpRPC)
- 为什么使用file_get_contents获取不到百度竞价内容
- PHP下通过file_get_contents()方法不能正常获取远程网页内容
- php 两种方法获取url内容 file_get_contents和curl
- PHP中使用file_get_contents抓取网页中文乱码问题解决方法
- file_get_contents 获取不了网页内容
- PHP中使用file_get_contents抓取网页中文乱码问题解决方法
- file_get_contents获取网页内容并且入库案例
- PHP使用file_get_contents或curl请求https的域名内容为空或Http 505错误的问题排查方法
- php使用fsockopen函数发送post,get请求获取网页内容的方法
- PHP 使用 stream_get_meta_date ,stream_get_contents 获取网页内容
- file_get_contents采集获取不到内容时用curl解决
- file_get_contents获取远程网页内容函数
- file_get_contents是打工文件或URL获取内容的方法,比其稳定的还有curl_get_contents
- php使用fsockopen函数发送post,get请求获取网页内容的方法
- VC使用Http Get方法获取页面内容
- file_get_contents函数获取不到数据的一种情况