Skip to content

Instantly share code, notes, and snippets.

@eiffelqiu
Created October 1, 2012 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiffelqiu/3810207 to your computer and use it in GitHub Desktop.
Save eiffelqiu/3810207 to your computer and use it in GitHub Desktop.
Convert html web to pdf
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://learnyousomeerlang.com/content'))
urls = [ 'http://learnyousomeerlang.com/content' ] + doc.xpath('//h3/a').map { |n| n.attribute('href').to_s }
exec("./wkhtmltopdf -s A4 #{ urls.join(' ') } learnyousomeerlang.pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment