Created
February 19, 2014 20:25
-
-
Save leeper/9100775 to your computer and use it in GitHub Desktop.
Get specified number of cat facts from the Cat Facts API (http://catfacts-api.appspot.com/)
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
library("RCurl") | |
library("RJSONIO") | |
catfacts <- function(number=1){ | |
if(is.null(number) || is.na(as.numeric(number)) || number < 1) | |
stop("'number' must be a positive integer") | |
fromJSON(getURL(paste('http://catfacts-api.appspot.com/api/facts?number=', number, sep='')))$facts | |
} | |
# Some examples | |
catfacts() | |
catfacts(5) | |
# ASCII cat saying cat facts | |
library("cowsay") | |
say(catfacts(),'cat') |
Author
leeper
commented
Feb 19, 2014
This is awesome - we must have this in cowsay
. Pull request?
Hi, the API seems to be unavailable. This is the error message:
"Python 2.5 is no longer available. Please refer to https://goo.gl/aESk5L for more information."
I can't find any info about the owner of the API so can't "complain" to them directly. I hope you have more info...
Cheers,
Lucas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment