require 'rubygems' require 'hpricot' require 'open-uri' links = []; search = %w[enter search keywords here]; search.each do |term| i = 0; 10.times do url = "http://www.google.com/blogsearch?hl=en&ie=UTF-8&q=#{term}&btnG=Search+Blogs" if i != 0 url = "http://www.google.com/blogsearch?hl=en&ie=UTF-8&q=#{term}&sa=N&start=#{i}" end page = Hpricot(open(url, 'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13', 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n', 'X-McProxyFilter' => '************\r\n', 'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n', 'Keep-Alive' => '300\r\n', 'Connection' => 'keep-alive\r\n')) page.search("//a[@class='f1']").each do |ln| link = ln.attributes['href']; if (links.index(link) == nil) puts link; links << link; end end i += 10 sleep(1 + rand(30)); end sleep(1 + rand(30)); end