Skip to content

Instantly share code, notes, and snippets.

@comeara
Created October 26, 2009 03:16
Show Gist options
  • Save comeara/218402 to your computer and use it in GitHub Desktop.
Save comeara/218402 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require "rubygems"
require "rbosa"
safari = OSA.app "Safari"
while(url = STDIN.gets) do
url.chomp!
STDERR.puts "Handling #{url}..."
safari.make OSA::Safari::Document, :with_properties => { :url => url }
sleep 5
safari.print safari.documents[0], :print_dialog => false
sleep 5
safari.close safari.documents[0]
end
#!/usr/bin/ruby
require "rubygems"
require "open-uri"
require "nokogiri"
root_url = "http://mephisto.theomearas.net"
root_doc = Nokogiri::HTML open(root_url)
monthly_archive_paths = root_doc.css("a").inject([]) do |paths, a|
paths << a["href"] if(a["href"] =~ %r(/archives))
paths
end
STDERR.puts "Searching #{monthly_archive_paths.size} monthly archives..."
article_paths = []
monthly_archive_paths.each do |archive_path|
monthly_archive_doc = Nokogiri::HTML open(root_url + archive_path)
monthly_archive_doc.css("a").each do |a|
article_paths << a["href"] if(a["href"] =~ %r(^/\d{4}/\d{1,2}/\d{1,2}/) && a["href"] !~ %r(#comments))
end
end
STDERR.puts "Found #{article_paths.size} articles"
article_paths.each { |path| STDOUT.puts(root_url + path) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment