Created
February 8, 2012 05:13
-
-
Save sosedoff/1765625 to your computer and use it in GitHub Desktop.
Fetch business price range from Yelp
This file contains 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
require 'faraday' | |
module Yelp | |
PRICE_RANGE_REGEX = /<span id="price_tip" \b[^>]*>(.*?)<\/span>/i | |
def self.restaurant_price_range(id) | |
url = "http://www.yelp.com/biz/#{id}" | |
body = Faraday.get(url).body | |
body.scan(PRICE_RANGE_REGEX).flatten.first.to_s.length | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment