Skip to content

Instantly share code, notes, and snippets.

@dchentech
Created September 13, 2012 14:17
Show Gist options
  • Save dchentech/3714601 to your computer and use it in GitHub Desktop.
Save dchentech/3714601 to your computer and use it in GitHub Desktop.
在豆瓣找房子ing
%w[open-uri nokogiri].map &method(:require)
@regexp = Regexp.new ENV['租房']
(0..19).to_a.map do |n|
html = Nokogiri open("http://www.douban.com/group/beijingzufang/discussion?start=#{n*25}")
html.css(".article table.olt tr td a").map {|i| {:title => i.attributes['title'].to_s, :href => i.attributes['href'].to_s}}.map do |h|
if h[:title].match @regexp
puts h.inspect
h[:href]
end
end
end.flatten.compact.each {|href| `open -a safari #{href}` }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment