Changed thecatapi usage to actual API URL
This commit is contained in:
Katya Demidova 2019-10-02 12:35:19 +03:00 committed by GitHub
commit 85f5cc5a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,6 @@
from .base import Base
from urllib.request import build_opener, HTTPRedirectHandler
import json
class Meow(Base):
@ -8,6 +9,7 @@ class Meow(Base):
def execute(self, command):
opener = build_opener(HTTPRedirectHandler)
req = opener.open('http://thecatapi.com/api/images/get?format=src')
with opener.open('https://api.thecatapi.com/v1/images/search') as r:
cats = json.loads(r.read())
self.send_photo(command, photo=req.url)
self.send_photo(command, photo=cats[0]['url'])