Skip to content

Instantly share code, notes, and snippets.

@thomasstr
Created April 4, 2013 18:30
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 thomasstr/5312857 to your computer and use it in GitHub Desktop.
Save thomasstr/5312857 to your computer and use it in GitHub Desktop.
#encoding: utf-8
require "rubygems"
require "open-uri"
require "json"
class Gulesider
def getData(data, country_name)
json_profile = "xxx"
json_apikey = "xxx"
json = JSON.parse(open("http://api.eniro.com/partnerapi/cs/search/basic?profile=#{json_profile}&key=#{json_apikey}&country=#{country_name}&version=1.1.3&search_word=#{data}").read)
json['adverts'].each do |advert|
puts advert['companyInfo']['companyName']
end
end
end
1.9.3-p392 :004 > g.getData("Ørsta", "no")
URI::InvalidURIError: bad URI(is not URI?): http://api.eniro.com/partnerapi/cs/search/basic?profile=strtho&key=1754304858815183099&country=no&version=1.1.3&search_word=Ørsta
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/uri/common.rb:176:in `split'
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/uri/common.rb:211:in `parse'
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/uri/common.rb:747:in `parse'
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/open-uri.rb:32:in `open'
from gulesider.rb:12:in `getData'
from (irb):4
from /usr/local/rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'
1.9.3-p392 :005 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment