PhantomJS笔记,Node.js集成PhantomJS

转 https://www.linchaoqun.com/html/cms/content.jsp?menu=index&id=1511140432245

http://phantomjs.org/

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();
})();

最新文章

  1. Node.js学习笔记——Node.js开发Web后台服务
  2. 根据网址把图片下载到服务器C#代码
  3. C#报修系统Ⅱ
  4. Recruit Coupon Purchase Winner's Interview: 2nd place, Halla Yang
  5. Android实现电子邮箱客户端
  6. C#Random()函数详解
  7. comet ajax轮询
  8. Linux下搭建Nginx+MySQL+PHP
  9. 面试(2)-java-se-HashSet和TreeSet
  10. node八-核心模块、包
  11. Asp.Net MVC 读取json文件
  12. 关于python中loc和iloc方法
  13. PDB文件详解
  14. jquery中遍历
  15. idea本地跑代码和链接开发机设置
  16. [OpenCV-Python] OpenCV 中的 Gui特性 部分 II
  17. llvm 编译
  18. 基于VRML的虚拟校园漫游系统
  19. 【LeetCode21】Merge Two Sorted Lists★
  20. layui文件上传进度条(模拟)

热门文章

  1. css transform解释及demo(基于chrome)
  2. vue脚手架引入MD5加密函数
  3. C++学习(9)—— 对象的初始化及清理
  4. Statefulset:部署有状态的多副本应用
  5. HDU-4794:Arnold(斐波拉契循环节 二次剩余)
  6. js回调与异步加载的用法
  7. can总线学习网上资料汇总
  8. tomcat catalina
  9. scala 学习笔记--模式匹配
  10. LeetCode 1100. Find K-Length Substrings With No Repeated Characters