Mechanize / Hpricot / Scraping setup
require 'rubygems' require 'cgi' require 'open-uri' require 'hpricot' require 'mechanize' agent = WWW::Mechanize.new doc = Hpricot(agent.get(the_url).parser.to_s)
11381 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
require 'rubygems' require 'cgi' require 'open-uri' require 'hpricot' require 'mechanize' agent = WWW::Mechanize.new doc = Hpricot(agent.get(the_url).parser.to_s)
require 'rubygems' require 'cgi' require 'open-uri' require 'hpricot' q = %w{meine kleine suchanfrage}.map { |w| CGI.escape(w) }.join("+") url = "http://www.google.com/search?q=#{q}" doc = Hpricot(open(url).read) lucky_url = (doc/"div[@class='g'] a").first["href"] system 'open #{lucky_url}'