I’m trying to figure out how to extract the information on a file using nokogiri.
The information generated isn’t an xml or html file.. so not sure how to get this!
def get_summoner_account
url = "http://elophant.com/api/v1/euw/getSummonerByName?summonerName=Heggom&key=0r57xO0H2A7ukQi6gUbG "
doc = Nokogiri::HTML(open(url))
name = doc.xpath("name").collect(&:text)
acctID = doc.xpath("acctID").collect(&:text)
summonerId = doc.xpath("summonerId").collect(&:text)
puts accID
puts name
puts summonerID
end
The data at the link you provided is in JSON format, not XML, so Nokogiri is not appropriate.
To get the data you want, you can just use Ruby’s Net::HTTP to get the data and JSON to parse it: