Forums

Whitelist request

its random.cat where you can get a random cat photo its api is at random.cat/meow

it returns a json response:

{"file":"http://random.cat/i/great-captions-28.jpg"}

and 'file' is the url to the cute cat photo

Here is some code that can grab x amount of photos:

import json
from urllib.request import urlretrieve  # Python 3
import urllib3


r = 1
c = input("how many cat photos?")
c = int(c)
while r < c+1:
     http = urllib3.PoolManager()
     j = http.request('GET','http://random.cat/meow')
    data = json.loads(j.data)
    link = data['file']
    filename = link.split('/')[-1]
    urlretrieve(link, filename)
    print("Finished number:"+str(r))
    r = r + 1

No problem! I see there's a link to the API on the front page for the domain, so I've whitelisted that now.