PHP中4种常用的抓取网络数据方法
本小节的名称为 fsockopen,curl与file_get_contents,具体是探讨这三种方式进行网络数据输入输出的一些汇总。关于 fsockopen 前面已经谈了不少,下面开始转入其它。这里先简单罗列一下一些常见的抓取网络数据的一些方法。 1. 用 file_get_contents 以 get 方式获取内容: 2. 用fopen打开url,以get方式获取内容 3. 用file_get_contents函数,以post方式获取url 'bar','baz'=>'boom','site'=>'www.52php.cn','name'=>'nowa magic');
$data = http_build_query($data); //$postdata = http_build_query($data); $url = "http://localhost/test2.php"; echo $result; 4、使用curl库,使用curl库之前,可能需要查看一下php.ini是否已经打开了curl扩展 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |