Browse Source

Load emojis from official unicode site

Emojipedia doesn't load anymore, unfortunately.
The other bad news is that while this one loads and is official, it does
not contain emojis with different skin colors.
They will have to be added later.
tags/2.0.0
Fabian Winter 2 years ago
parent
commit
31d91abafb
2 changed files with 1638 additions and 7821 deletions
  1. 11
    7
      extract_emojis.py
  2. 1627
    7814
      rofimoji.py

+ 11
- 7
extract_emojis.py View File

@@ -1,9 +1,10 @@
import requests
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup, NavigableString

max_tries = 5
for i in range(max_tries):
data = requests.get('https://emojipedia.org/emoji/') # type: requests.Response
for i in range(max_tries):
print("Downloading emojis... try %s" % (i + 1))
data = requests.get('https://www.unicode.org/emoji/charts-11.0/full-emoji-list.html', timeout=60) # type: requests.Response
if data:
break

@@ -12,15 +13,18 @@ if not data:
exit(10)

soup = BeautifulSoup(data.content, 'lxml') # type: BeautifulSoup
table = soup.find('table')

python_file = open('emojis.py', 'w')
python_file.write('emojis="""')

for table_row in soup.find_all('tr'):
emoji_row = table_row.find('td')
text = emoji_row.get_text()
for row in table.find_all('tr'):
if row.th:
continue
emoji = row.find('td', {'class': 'chars'}).string
description = row.find('td', {'class': 'name'}).string.replace('⊛ ', '')

python_file.write(text + '\n')
python_file.write(emoji + " " + description + '\n')
python_file.write('"""')

python_file.close()

+ 1627
- 7814
rofimoji.py
File diff suppressed because it is too large
View File


Loading…
Cancel
Save