PhantomJS笔记,Node.js集成PhantomJS
2024-09-01 17:23:47
PhantomJS笔记,Node.js集成PhantomJS
转 https://www.linchaoqun.com/html/cms/content.jsp?menu=index&id=1511140432245
https://github.com/ariya/phantomjs
https://www.npmjs.com/package/phantom
https://github.com/amir20/phantomjs-node
PhantomJS
phantom:幽灵
一个看不见摸不着的浏览器
PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.
PhantomJS抓取网页生成png
var page = require('webpage').create();page.open('http://www.linchaoqun.com', function(status) {
console.log("Status: " + status);
if(status === "success") {
page.render('example.png');
}
phantom.exit();
});
phantomjs hello.js
Node.js集成PhantomJS
npm install phantom --save
const phantom = require('phantom');
(async function() {
const instance = await phantom.create();
const page = await instance.createPage();
await page.on('onResourceRequested', function(requestData) {
console.info('Requesting', requestData.url);
});
const status = await page.open('http://www.linchaoqun.com/');
const content = await page.property('content');
console.log(content);
page.render('example.png');
await instance.exit();
})();
最新文章
- Node.js学习笔记——Node.js开发Web后台服务
- 根据网址把图片下载到服务器C#代码
- C#报修系统Ⅱ
- Recruit Coupon Purchase Winner's Interview: 2nd place, Halla Yang
- Android实现电子邮箱客户端
- C#Random()函数详解
- comet ajax轮询
- Linux下搭建Nginx+MySQL+PHP
- 面试(2)-java-se-HashSet和TreeSet
- node八-核心模块、包
- Asp.Net MVC 读取json文件
- 关于python中loc和iloc方法
- PDB文件详解
- jquery中遍历
- idea本地跑代码和链接开发机设置
- [OpenCV-Python] OpenCV 中的 Gui特性 部分 II
- llvm 编译
- 基于VRML的虚拟校园漫游系统
- 【LeetCode21】Merge Two Sorted Lists★
- layui文件上传进度条(模拟)