摘要: 方法1: 用file_get_contents 以get方式获取内容方法2:用file_get_contents函数,以post方式获取url 'bar');$data = http_build_query($data);$opts = array ('http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Cont 阅读全文
posted @ 2013-11-18 10:52 btohad 阅读(357) 评论(0) 推荐(0) 编辑
摘要: 用php抓取页面的内容在实际的开发当中是非常有用的,如作一个简单的内容采集器,提取网页中的部分内容等等抓取到的内容在通过正则表达式做一下过滤就得到了你想要的内容,至于如何用正则表达式过滤,在这里就不做介绍了,有兴趣的,以下就是几种常用的用php抓取网页中的内容的方法。1.file_get_contents PHP代码 2.curl PHP代码 3.fopen->fread->fclose PHP代码 注: 1.使用file_get_contents和fopen必须空间开启allow_url_fopen。方法:编辑php.ini,设置allow_url_fopen = On,allo 阅读全文
posted @ 2013-11-18 10:46 btohad 阅读(151) 评论(0) 推荐(0) 编辑