Skip to content

Instantly share code, notes, and snippets.

@clamytoe
Created July 15, 2018 17:23
Show Gist options
  • Save clamytoe/eddc08a212248215a4add96404da39d4 to your computer and use it in GitHub Desktop.
Save clamytoe/eddc08a212248215a4add96404da39d4 to your computer and use it in GitHub Desktop.
emoji.py
import requests
from bs4 import BeautifulSoup
def get_soup():
url = 'https://www.webpagefx.com/tools/emoji-cheat-sheet/'
page = requests.get(url)
if page.ok:
soup = BeautifulSoup(page.content, 'html.parser')
spans = soup.find_all('span', {'class': 'name'})
return spans
return None
def parse_soup(soup):
for span in soup:
alt = span.alternatives
name = span.text
emoji = r'"\N{' + name.replace('_', ' ') + r'}"'
try:
print(eval(emoji), end='')
print(f': {name}', end='\n')
except SyntaxError:
pass
def main():
soup = get_soup()
parse_soup(soup)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment