如何通过API获取twich表情??

2024-05-13 19:58:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要下载twich.电视表情。我找到了Phyton脚本,但那没用。编写脚本的人说Twich activate cloudfare或etc.page with API doc

import urllib
import os
import json

if not os.path.exists('./emotes'):
    os.makedirs('./emotes')
print('Saving emotes to folder: ' + os.path.abspath('./emotes') + '...')
print('Grabbing emote list...')
emotes = json.load(urllib.urlopen('https://twitchemotes.com/api_cache/v2/global.json'))
for code, emote in emotes['emotes'].items():
    print('Downloading: ' + code + '...')
    urllib.urlretrieve('http:' + emotes['template']['large'].replace('{image_id}', str(emote['image_id'])),
                       './emotes/' + code + '.png')
print('Done! Kappa')

Tags: pathimageimport脚本idjsonoscode
6条回答

是的,我觉得API已经不起作用了。似乎您可以使用https://api.twitch.tv/kraken/chat/emoticons/,但是:

import urllib
import os
import json

if not os.path.exists('./emotes'):
    os.makedirs('./emotes')
print('Saving emotes to folder: ' + os.path.abspath('./emotes') + '...')
print('Grabbing emote list...')
emotes = json.load(urllib.urlopen('https://api.twitch.tv/kraken/chat/emoticons/'))
for emote in emotes['emoticons']:
    code = emote['regex']
    print('Downloading: ' + code + '...')
    urllib.urlretrieve(emote['images'][0]['url'], './emotes/' + code + '.png')
print('Done! Kappa')

相关问题 更多 >