Seeing a cat image or GIF by using the Cat API
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
# -*- encoding: UTF-8 -*- | |
require 'nokogiri' | |
require 'open-uri' | |
API_URL = "http://thecatapi.com/api/images/get?format=xml" | |
doc = Nokogiri::XML(open(API_URL).read) | |
url_nodes = doc.xpath("//url").text | |
puts url_nodes | |
# open browser | |
system "open " + url_nodes |
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
<?xml version="1.0"?> | |
<response> | |
<data> | |
<images> | |
<image> | |
<url>http://25.media.tumblr.com/qgIb8tERinzopu0j9Alm3YrHo1_500.jpg</url> | |
<id>8dd</id> | |
<source_url>http://thecatapi.com/?id=8dd</source_url> | |
</image> | |
</images> | |
</data> | |
</response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment