Maison > Article > développement back-end > javascript - js如何采集页面
一般通过curl、file_get_contents来采集,如:
<code class="lang-php">$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); </code>
一般通过curl、file_get_contents来采集,如:
<code class="lang-php">$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); </code>
node+1,比如这货http://phantomjs.org/
js由于有跨域问题,是不能做采集任务的,不过你可以考虑下node.js