用CURL来实现file_get_contents函数:curl_file_get_contents
<?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的更多相关文章
- PHP file_get_contents函数读取远程数据超时的解决方法
PHP file_get_contents函数读取远程数据超时的解决方法 投稿:junjie 字体:[增加 减小] 类型:转载 这篇文章主要介绍了PHP file_get_contents函数读取 ...
- PHP file_get_contents() 函数
定义和用法 file_get_contents() 函数把整个文件读入一个字符串中. 和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串. file_get ...
- PHP基础之 file_get_contents() 函数
定义和用法 file_get_contents() 函数把整个文件读入一个字符串中. 和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串. file_get ...
- 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 ...
- 给file_get_contents函数设置超时时间
$opts = array( 'http'=>array( 'method'=>"GET", 'timeout'=>60, ) ); $context = str ...
- curl重写php file_get_contents
file_get_contents在连接不上的时候会提示Connection refused,有时候会带来不便:另外,curl的性能比file_get_contents高,所以用curl重写file_ ...
- PHP-CGI 进程 CPU 100% 与 file_get_contents 函数的关系
[文章作者:张宴 本文版本:v1.0 最后修改:2011.08.05 转载请注明原文链接:http://blog.s135.com/file_get_contents/] 有时候,运行 Nginx.P ...
- php -- PHP5中file_get_contents函数获取带BOM的utf-8文件内容
最近,在用file_get_contents函数来取得文本的内容的时候,出现了一个情况(如下),苦思冥想了n久,不得其解,最后,果然还是得靠百度啊..... 百度到一个解释,下面是原文: PHP5中的 ...
- file_get_contents函数
今天迁移一个SDK项目到新的机子上,发现项目无法跑起来,报500错误,通过分析,发现原来是file_get_contents函数再作怪,代码如下 public function __construct ...
随机推荐
- MySQL索引详解
导读:大家都知道,一个MySQL数据库能够储存大量的数据,如果要查找那一个数据,就得费好大劲从一大堆的数据中找到,即费时间又费力气,这时,索引的出现就大大减轻了数据库管理员的工作.本文介绍了数据库索引 ...
- 为 ASP.NET Web API 创建帮助页
http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages 以前实例 ...
- Activiti源码浅析:Activiti的活动授权机制
1. IdentityLink与TaskEntity An identity link is used to associate a task with a certain identity. For ...
- FusionChart 导出图片 功能实现(转载)
FusionChart 导出图片 功能实现(转载) http://www.cnblogs.com/jiagoushi/archive/2013/02/05/2893468.html 题目:精美Fusi ...
- C#下如何用NPlot绘制期货股票K线图(1)?
[简介] 作为一名专业程序化交易者,编程是一个程序员的基本功,本文是作者在做的一个期货CTP项目中有关K线绘图的一部分,偿试类MT4中图表 设计而写,在编写绘图时,查阅了相关资料,感觉还是用NPlot ...
- Dorado事件的参数
onClick,onSuccess 事件一般只有2个参数(self,arg),其实参数是可以添加的.可以把控件的ID直接放到参数里面来,然后在事件编辑里直接通过ID作控件对象,直接设值就好了,不要输入 ...
- iOS 简单理解类的本质
1.类也是个对象 类是一个对象是Class类型的对象简称类对象 Class类型的定义 // 一个任意的类型,表示一个Objective-C类 typedef struct objc_class *Cl ...
- QtSQL学习笔记(4)- 使用SQL Model类
除了QSqlQuery,Qt提供了3个高级类用于访问数据库.这些类是QSqlQueryModel.QSqlTableModel和QSqlRelationalTableModel. 这些类是由QAbst ...
- WebBench简介
/** @brief Web Bench Description* @author Tang Huaming* @qq 1426213638* @E-mail xiaoma ...
- 由Double类型数据到数据的格式化包java.text
需求:Double类型数据截取操作保留两位小数 解决方案: java.text.DecimalFormat df =new java.text.DecimalFormat("#.00&quo ...