The code academy example has me using ruby, which I’m not really familiar with (I did their course like a year ago and vaguely remember some stiff), but the gist was the following:
First, you’ll want to require the ‘open-uri’ module, which is the ruby way of bringing in additional methods and constraints to make the HTTP request. A module is a bucket of extra Ruby tools.
require = ‘open-uri’
Next, you’ll want to declare a variable and have it open the url we’re grabbing from.
kittens = open(‘http://placekitten.com/’)
This prepares us for the GET request we do next, which is slightly confusing because it’s not written as GET but instead as ‘read’, which is another ruby term (I’m hesitant to call it a method, but that’s what I think it is. Apparently methods are words you use to execute other programmers’ code).
body = kittens.read[559, 441]
So, what happened above: I believe I set a variable called body, and set it equal to my other variable kittens, with the read method enacted on it for the specific character numbers listed. Although I’m not sure what they mean by character numbers, and I forget if the way it’s written implies just those two numbers, or everything in between.
Finally, I use the puts method on the body variable so I can see the data I got back on the line where I opened the placekitten url.
I included a screenshot to show what this looked like, and the result: