Skip to content

Instantly share code, notes, and snippets.

@iAmMrinal0
Forked from ArionMiles/slack_emoji_downloader.py
Last active August 21, 2018 12:59
Show Gist options
  • Save iAmMrinal0/eca75dabb3619989713f7654a5819c00 to your computer and use it in GitHub Desktop.
Save iAmMrinal0/eca75dabb3619989713f7654a5819c00 to your computer and use it in GitHub Desktop.
Download slack custom emojis
import requests
from bs4 import BeautifulSoup
#slack_emojis.html is the source of the slack custom emoji page, available at https://dev-s.slack.com/customize/emoji
#create a folder `output` in the current directory so all the emojis are saved there
file = open('slack_emojis.html', 'r')
soup = BeautifulSoup(file, 'html.parser')
custom_emoji = soup.find('table', {'id':'custom_emoji'})
emoji_rows = custom_emoji.find_all('tr', {'class': 'emoji_row'})
for emoji_row in emoji_rows:
emoji_url = emoji_row.span['data-original']
emoji_name = emoji_row.find('td', {'headers':'custom_emoji_name'}).text
filename = emoji_name.strip()[1:-1]
ext = emoji_url[-3:]
path = f'output/{filename}.{ext}'
imgdata = requests.get(emoji_url, stream=True)
with open(path, 'wb') as output:
output.write(imgdata.content)
print(f"Saved {filename}.{ext}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment