Skip to content

Instantly share code, notes, and snippets.

@sosedoff
Created February 8, 2012 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sosedoff/1765625 to your computer and use it in GitHub Desktop.
Save sosedoff/1765625 to your computer and use it in GitHub Desktop.
Fetch business price range from Yelp
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