用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 ...
随机推荐
- PeopleReady--办公学习类App产品
PeopleReady是能使人(公司或组织里的员工)快速Ready(经验+知识)的学习系统.对员工的好处是:- 可以迅速Ready,尽快符合岗位要求,尽快有Performance,尽快对公司有价值,从 ...
- MVC 表单提交提示:已添加了具有相同键的项。
MVC:页面提交的时候报如下错误: 解决方案: 这个Model 里面定义了重复的字段so~~~
- Android更改桌面应用程序launcher的两种方式
http://blog.csdn.net/mdx20072419/article/details/9632779/ launcher,也就是android的桌面应用程序.下图是我正在使用的魅族手机的l ...
- PHP 实现对象的持久层,数据库使用MySQL
http://www.xuebuyuan.com/1236808.html 心血来潮,做了一下PHP的对象到数据库的简单持久层. 不常用PHP,对PHP也不熟,关于PHP反射的大部分内容都是现学的. ...
- C#构造函数相关主题
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- Python的对象操作(一)
python支持对象和函数 1. python是解释型语言,逐行运行 2. 对象调用 例子:删除文件的一个例子 2.1 先定义一个类 class MyApp: 2.2 import 引用要用到的模 ...
- C语言的奇技
1.一个整型变量/字面值常量通常足够大,可以同时表示几个字符,所以有的C编译器允许字符常量/char及整型常量有多个字符.这表明当用' yes' 替代" yes" 时可能不会被发现 ...
- Linux中的安装神器--yum源安装
linux配置yum源 一.修改yum的配置文件 /etc/yum.repos.d/xxx.repo 1.进入yum配置文件目录 # cd /etc/yum.r ...
- Apache服务
Apache服务的安装: Apache服务程序的软件包名称是:httpd 安装方法: rpm软件包安装.源码编译安装.yum安装 yum install httpd 安装完成后启动: revice h ...
- opensuse安装mysql-workbench
首先安装好mysqlserver,做本地测试其实不用安装mysqlclient. 到http://software.opensuse.org/package/mysql-workbench 下载相应版 ...