用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 ...
随机推荐
- .NET学习笔记(2) — IIS服务器环境搭建
目录 一:开启Windows系统自带的IIS服务器方法 二:备注 三:常见问题 一:开启Windows系统自带的IIS服务器方法 第一步:安装IIS,控制面板->程序和功能-> ...
- git命令(流程)
1,配置你的信息: git config --global user.name 你的名字 git config --global user.email 你的邮箱 --global 表示所有git仓库都 ...
- 对象创建型模式------Abstract Factory(抽象工厂)
1. 意图 提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类.2. 别名 Kit3. 动机 假设我们要开发一款游戏,当然为了吸引更多的人玩,游戏难度不能太大 ...
- 查看帮助文档的一些方法:help,dir,type,func_global等
help与dir与type:在使用python来编写代码时,会经常使用python自带函数或模块,一些不常用的函数或是模块的用途不是很清楚,这时候就需要用到help函数来查看帮助.这里要注意下,hel ...
- 使用c#生成Identicon图片
Identicon是什么 我们在站点注册的时候通常系统会在我们没有提供自定义头像时为我们指定一个默认的头像,不过,样子千篇一律很是难看.聪明的程序员想了很多办法来解决这个问题,比如你能在这里看到很漂亮 ...
- ###Markdown初步学习
Markdown学习/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) *//* Author: Nicolas Hery - ...
- 判断手机还是PC浏览器
function goPAGE() { if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobi ...
- 移动前端开发之viewport的深入理解(转载)
本文为转载文章,原文网址:http://www.cnblogs.com/2050/p/3877280.html 在移动设备上进行网页的重构或开发,首先得搞明白的就是移动设备上的viewport了,只有 ...
- QT/C++ 智能指针
什么是智能指针? 为什么用智能指针? 还有哪些关于内存管理方面的知识点,需要注意的?
- How to enable $Admin Shares in Windows 7
Quote from: http://www.wintips.org/how-to-enable-admin-shares-windows-7/ As “Administrative shares” ...