Project

masque

0.01
No commit activity in last 3 years
No release in over 3 years
JavaScript enabled web crawler kit
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Build Status Coverage Status Code Climate Gem Version

Masque

女面

Masque is a browser emulated crawler builder wrapping capybara-webkit and poltergeist.

Installation

You need Xvfb and QT libraries before installing Masque gem.

On Debian/Ubuntu:

$ sudo apt-get install libqt4-dev xvfb libicu48 ttf-ubuntu-font-family
$ gem install masque

On Mac OS X (assumes you have Homebrew installed):

$ brew install qt
$ gem install masque

Usage

Easy crawling websites they required JavaScript.

require "masque"
m = Masque.new(:display => 99, :driver => :webkit) # or :driver => :poltergeist
m.run do
  # Capybara::DSL syntax
  # https://github.com/jnicklas/capybara#the-dsl

  visit "http://www.google.com/"
  fill_in("q", :with => "capybara")
  find('*[name="btnG"]').click

  titles = evaluate_script <<-JS
    (function(){
      var titles = Array.prototype.map.call(
        document.querySelectorAll('h3 a'),
        function(a) {
          return a.innerText;
        }
      );

      return titles;
    })();
  JS
  puts titles.join("\n")
end

more examples are available in examples/ directory.

TODO

  • Impl useful DSL
  • Respect driver specific features/options

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request