码迷,mamicode.com
首页 > Web开发 > 详细

用CURL来实现file_get_contents函数:curl_file_get_contents

时间:2015-07-28 12:38:48      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:

<?php
$url=‘http://www.bamuyu.com/news/zixun/list_7_2.html‘;
$content=curl_file_get_contents($url);
echo $content;


function curl_file_get_contents($durl){
   $cookie_file = dirname(__FILE__)."/cookie.txt";
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $durl);
   curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER[‘HTTP_USER_AGENT‘]);
   curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
   $r = curl_exec($ch);
   curl_close($ch);
   return $r;
 }

 

用CURL来实现file_get_contents函数:curl_file_get_contents

标签:

原文地址:http://www.cnblogs.com/kenshinobiy/p/4682220.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!