首页 > js如何采集页面

js如何采集页面

php采集页面

一般通过curl、file_get_contents来采集,如:

$ch=curl_init($post_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0");
$con=curl_exec($ch);

js也能采集页面吗,有什么方法?


js由于有跨域问题,是不能做采集任务的,不过你可以考虑下node.js


node+1,比如这货http://phantomjs.org/

【热门文章】
【热门文章】