A Ruby gem that scrapes images from websites (including JavaScript-heavy ones) and compiles them into a PDF.
Add this line to your application's Gemfile:
gem 'koralreef'And then execute:
$ bundle installOr install it yourself as:
$ gem install koralreef# Basic usage (scrapes all images)
$ koralreef https://example.com/gallery
# Scrape specific images with a CSS selector
$ koralreef -s ".product-image" https://example.com/products
# Specify output file
$ koralreef -o product_catalog.pdf https://example.com/products
# Run with visible browser (not headless)
$ koralreef --no-headless https://example.com/galleryrequire 'koralreef'
# Basic usage
pdf_file = Koralreef.run(
url: "https://example.com/gallery",
selector: "img.gallery-image",
output_file: "gallery.pdf",
headless: true
)
puts "PDF created at: #{pdf_file}"After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install.
Bug reports and pull requests are welcome on GitHub at https://github.com/uminocelo/koralreef.
The gem is available as open source under the terms of the MIT License.