Created
September 13, 2012 14:17
-
-
Save dchentech/3714601 to your computer and use it in GitHub Desktop.
在豆瓣找房子ing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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