Skip to content

Instantly share code, notes, and snippets.

@DRMacIver
Created August 29, 2009 19:21
Show Gist options
  • Select an option

  • Save DRMacIver/177630 to your computer and use it in GitHub Desktop.

Select an option

Save DRMacIver/177630 to your computer and use it in GitHub Desktop.
require "rubygems"
require "mechanize"
@mechanize = WWW::Mechanize.new{|agent| agent.user_agent_alias = "Linux Mozilla"}
STDOUT.sync = false
def fetch_data(url)
STDERR.puts "fetching #{url}"
urls = @mechanize.get(url).search("a").map{|x| x['href']};
gists = urls.select{|x| x =~/^\/\d+$/}.map{|x| x[1..-1]}
puts gists
STDOUT.flush
urls.select{|x| x =~ /^\/.+?page=/}[-1]
end
def fetch_gists(user)
url = "http://gist.github.com/#{user}"
while url = fetch_data(url)
end
end
fetch_gists ARGV[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment