Home >Backend Development >PHP Tutorial >javascript - js如何采集页面

javascript - js如何采集页面

WBOY
WBOYOriginal
2016-06-06 20:49:041290browse

php采集页面

一般通过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>

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

回复内容:

php采集页面

一般通过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>

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

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

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn