Giter VIP home page Giter VIP logo

booh's Introduction

booh

This project is a tiny proof of concept to make screenshots of websites with nodejs and the QtWebKit webview.

The goal is to be able to make screenshots on a headless server from a rich scriptable environment.

Example

var booh = require('booh');

var browser = new booh.Browser();
browser.load('http://github.com');
browser.on('loadFinished', function () {
    browser.screenshot('github.png');
});

Requirements

  • Linux only
  • Qt5, Qt5WebKit and Qt development utilities (essentially the moc command)

Installation

npm install git://github.com/BenoitZugmeyer/booh.git

To ArchLinux users: you may want to prepend PYTHON=python2 to this command.

Documentation

All this API is in development and may change at any time.

booh.Browser

The main class. Each browser are independent. It implements the node EventEmitter class.

booh.Browser methods

close()

This will free the underlying view. You have to close all the browsers to stop the node event loop (and gracefully stop the node process).

load(url)

Load a given URL in the browser.

screenshot(outputFile)

Takes a screenshot and store it as a PNG file.

setSize(size)

Set the size of the browser. Without argument, the browser will be resized to fit its current content. Else, it should be an object with optional properties width and height describing a size in pixels. Any missing property will be replaced by the current content metric.

Note: the default size is 1024 x 768.

show()

Show the browser. An interactive window will be opened. You can use this to check what's wrong with the website. There is no hide() yet.

setUserAgent(useragent)

Set the user agent.

booh.Browser events

You can register events with the node events api methods. Each event will have one object as argument.

loadProgress

Emitted when a page is being loaded.

event.progress number from 0 to 100: the current load status

loadFinished

Emitted when the page is loaded. This does not handle asynchronous assets loading.

event.success boolean: the global success of the page load.

requestFinished

An HTTP request has finished.

event.url string: the URL of the response

event.headers array: all response headers

event.request object: the source request

event.request.url string: the requested URL

event.request.headers array: all request headers

Credits

My C++ and Qt skills are a little rusty. I used this qt-project example as a starting point.

The integration of Qt into nodejs is greatly inspired from node-qt.

booh's People

Contributors

benoitzugmeyer avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.