Home> php教程> php手册> body text

PhantomJS简单实例

WBOY
Release: 2016-06-13 11:30:27
Original
1476 people have browsed it

PhantomJS是以WebKit为核心并提供JavaScript编程接口(API)的无界面浏览器。 它提供对web标准的快速并且原生的支持: DOM操作、CSS选择符、JSON、Canvas和SVG。

1.下载解压PhantomJS http://phantomjs.org/

2.编写简单的测试代码, 保存为test.js, 解压后phantomjs\examples下有大量实例可供参考

console.log('Loading a web page' page = require('webpage' url = 'http://www.phantomjs.org/'  (status !== 'success''Unable to post!'
Copy after login

3.因为我使用的是windows, 所以进入CMD命令行模式运行test.js, 并使用管道符将结果输出到test.txt. 如果不用管道的话,会直接输出结果。

.

4.因为PhantomJS支持命令行,所以在开发过程中我们可以使用PHP, Java, 或者Python直接获取结果就OK了

source:php.cn
Statement of this Website
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
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!