Created
September 9, 2012 11:46
-
-
Save empr/3683946 to your computer and use it in GitHub Desktop.
Make pdf from url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'open-uri' | |
require 'pdfkit' | |
if __FILE__ == $0 | |
url = ARGV[0] | |
doc = Nokogiri::HTML(open(url)) | |
filename = doc.title ? "#{doc.title.strip}.pdf" : "#{url}.pdf" | |
puts filename | |
pdf = PDFKit.new(url) | |
pdf.to_pdf | |
pdf.to_file(filename) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment