做采集的时候,可以使用file_get_contents()去获取网页源代码,但是使用file_get_contents采集,速度慢,而且超时时间,不好控制。如果采集的页面不存在,需要等待的时间很长。一般来说,curl的速度最快,其次是socket,最后是file_get_contents。现在跟大...
分类:
Web程序 时间:
2015-02-04 10:41:06
阅读次数:
159
1、file_get_contents获取文本或者网页的内容string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [...
分类:
Web程序 时间:
2015-02-03 22:43:51
阅读次数:
235
文件名:test.xml方法一:读取文件到一个字符串,通过解析字符串:$url = "http://localhost/test/test.xml";$xmlString=file_get_contents($url);$xml_array=simplexml_load_str...
分类:
Web程序 时间:
2015-02-03 19:21:37
阅读次数:
130
1.以文件流形式接受POST过来的数据:$params=file_get_contents(‘php://input‘);2.parse_url解析url,返回其组成部分。例如:$php-r‘print_r(parse_url("http://username:password@hostname/path?arg=value#anchor"));‘
Array
(
[scheme]=>http
[host]=>hostname
[user]=..
分类:
Web程序 时间:
2015-02-03 17:30:22
阅读次数:
247
<?php
error_reporting(0);//这个最好加上 因为file_get_contents遇到目录时会出错$key=$_GET['key'];$dir=dirname(__FILE__);$file=scandir($dir);foreach($file as $f){$tmp=file_get_contents($f,1024*100);if(stripos($tmp,$ke...
分类:
Web程序 时间:
2015-01-28 14:48:16
阅读次数:
190
今晚开放ecmall商城的QQ登陆功能,在回调时产生错误,file_get_contents函数执行时,没有抓取到正确的信息,于是改用curl,但是提示证书错误。 在网上找到了解决方法,就是去掉证书认证。 curl_setopt($ch,?CUR...
分类:
Web程序 时间:
2015-01-26 21:13:48
阅读次数:
185
方法1: 用file_get_contents 以get方式获取内容[php] view plaincopyprint?方法2: 用fopen打开url, 以get方式获取内容[php] view plaincopyprint?while(!feof($fp)) {$result .= fgets(...
分类:
Web程序 时间:
2015-01-25 16:30:29
阅读次数:
221
= 0 ? 'http://dev-mcc.planetart.com' : SiteSettings::getDomain(SITE_MCC);$htmlOverview = file_get_contents($domain.'/planetart_dashboard.php?overvi...
分类:
Web程序 时间:
2015-01-22 21:29:32
阅读次数:
240
file_get_contents无法请求https连接的解决方法方法1:PHP.ini默认配置下,用file_get_contents读取https的链接,就会如下错误:Warning: fopen() [function.fopen]: Unable to find the wrapper "h...
分类:
Web程序 时间:
2015-01-22 17:42:23
阅读次数:
207
fread()、fgets()、fgetc()、file_get_contents() 与 file() 函数用于从文件中读取内容。 fread() fread()函数用于读取文件(可安全用于二进制文件) 语法:string fread(int handle,int length) fr...
分类:
Web程序 时间:
2015-01-20 21:57:29
阅读次数:
248