Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 28 lines (20 sloc) 637 Bytes
#!/usr/bin/env ruby
# frozen_string_literal: true
# uspatent.rb
# Author: William Woodruff
# ------------------------
# Fetches a filed US patent by number in PDF format.
# ------------------------
# This code is licensed by William Woodruff under the MIT License.
# http://opensource.org/licenses/MIT
require "net/http"
URL = "https://patentimages.storage.googleapis.com/pdfs/%<patent>s"
number = ARGV.shift
abort "Usage: #{$PROGRAM_NAME}: <patent #>" if number.nil?
patent = "US#{number}.pdf"
url = URL % { patent: patent }
begin
File.write patent, Net::HTTP.get(URI(url))
rescue Net::HTTPError => e
abort "Fatal: #{e}"
end