<?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的更多相关文章

  1. PHP file_get_contents函数读取远程数据超时的解决方法

    PHP file_get_contents函数读取远程数据超时的解决方法 投稿:junjie 字体:[增加 减小] 类型:转载   这篇文章主要介绍了PHP file_get_contents函数读取 ...

  2. PHP file_get_contents() 函数

    定义和用法 file_get_contents() 函数把整个文件读入一个字符串中. 和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串. file_get ...

  3. PHP基础之 file_get_contents() 函数

    定义和用法 file_get_contents() 函数把整个文件读入一个字符串中. 和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串. file_get ...

  4. PHP文件操作,多行句子的读取,file()函数,file_get_contents()函数,file_put_contents()函数,is_file,统计网站pv (访问量),文件的复制 copy,文件重命名 rename,删除文件 unlink

    php中添加utf-8: header("Content-type:text/html;charset='UTF-8'"); 文件操作步骤: 1.在同一目录下建立一个file.tx ...

  5. 给file_get_contents函数设置超时时间

    $opts = array( 'http'=>array( 'method'=>"GET", 'timeout'=>60, ) ); $context = str ...

  6. curl重写php file_get_contents

    file_get_contents在连接不上的时候会提示Connection refused,有时候会带来不便:另外,curl的性能比file_get_contents高,所以用curl重写file_ ...

  7. PHP-CGI 进程 CPU 100% 与 file_get_contents 函数的关系

    [文章作者:张宴 本文版本:v1.0 最后修改:2011.08.05 转载请注明原文链接:http://blog.s135.com/file_get_contents/] 有时候,运行 Nginx.P ...

  8. php -- PHP5中file_get_contents函数获取带BOM的utf-8文件内容

    最近,在用file_get_contents函数来取得文本的内容的时候,出现了一个情况(如下),苦思冥想了n久,不得其解,最后,果然还是得靠百度啊..... 百度到一个解释,下面是原文: PHP5中的 ...

  9. file_get_contents函数

    今天迁移一个SDK项目到新的机子上,发现项目无法跑起来,报500错误,通过分析,发现原来是file_get_contents函数再作怪,代码如下 public function __construct ...

随机推荐

  1. Centos 6.5 安装 chrome , mplayer , alarm , clock

    http://my.oschina.net/jianweizhang/blog/306946 Chrome wget http://chrome.richardlloyd.org.uk/install ...

  2. [记录] web icon 字体

    weloveiconfonts  在http://codepen.io/cguillou/pen/jmkfK 中看css发现既然有这样的,yes!

  3. 优雅的使用 PhpStorm 来开发 Laravel 项目

    [目录] Prerequisites plugin installation and configuration 1 Ensure Composer is initialized 2 Install ...

  4. ASP缓存类收集

    木鸟写的 '********************************************** ' vbs Cache类 ' ' 属性valid,是否可用,取值前判断 ' 属性name,ca ...

  5. .net 文件操作

    一.DotNet文件目录常用操作: DiveInfo:提供了对逻辑磁盘的基本信息访问的途径.(只能查看信息,不能做任何修改.) System.Environment:用来枚举驱动器.(不能获取驱动器的 ...

  6. Agile.Net 组件式开发平台 - 开发环境部署

    环境准备: Windows 7 (32/64) Windows Server 2008 (32/64) Microsoft SQL Server 2008 R2 (32/64) Microsoft V ...

  7. 打包C#程序

    开源中国. 今天来使用VS2010对C#程序进行打包发布. 我们有一个C#程序.程序很简单,我们需要对它进行发布. Contents 步骤: 建立一个安装项目.我们得到了一个Setup1项目. 在应用 ...

  8. 简化版的Flappy Bird开发过程(不使用第三方框架)

    目录 .1构造世界 .2在世界中添加元素 .3碰撞检测 .4添加动画特效 .5总结 .0 开始之前 之前曾经用Html5/JavaScript/CSS实现过2048,用Cocos2d-html5/Ch ...

  9. 10_HTTP协议_入门知识

    [什么是HTTP协议] 对 浏览器客户端 和  服务器端之间的数据传输的格式规范. 客户端连上web服务器后,若想获得web服务器中的某个web资源,需遵循一定的通讯格式,HTTP协议用于定义客户端与 ...

  10. bzoj4637:期望

    思路:最小生成树计数只不过加了一个期望,由于期望具有线性性质,就可以转化为每条边的期望之和,那么一条边的期望如何求呢,在最小生成树记数中,是把相同边权的一起处理,之后把属于连通块内的点缩点,也就是说, ...