-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chenghao Mou
authored and
Chenghao Mou
committed
Jun 27, 2019
1 parent
ff37fa2
commit 377be00
Showing
8 changed files
with
1,479 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ statistics.py | |
report.md | ||
dist/* | ||
elisa_dnt.egg-info/* | ||
/elisa.train_1.swa | ||
/visual.html | ||
/elisa.train_1.swa.del.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# encoding: utf-8 | ||
# Created by chenghaomou at 2019-06-27 | ||
|
||
from bs4 import BeautifulSoup | ||
import urllib3 | ||
import argparse | ||
|
||
|
||
def get_emojis(url: str = "http://unicode.org/emoji/charts-12.0/full-emoji-list.html", | ||
output: str = "emojis.ini") -> None: | ||
""" | ||
Parse the official website for all emojis and write them to a file. | ||
:param url: Official unicode website for emoji list. | ||
:param output: Output file for the list of emojis. | ||
:return: None. | ||
""" | ||
req = urllib3.PoolManager() | ||
res = req.request('GET', url) | ||
soup = BeautifulSoup(res.data, "html.parser") | ||
emojis = set('🦰🦱🦳🦲🏻🏼🏽🏾🏿') | ||
for img in soup.findAll('img', alt=True): | ||
if len(img['alt']) == 1: | ||
emojis.add('{}'.format(img['alt'])) | ||
|
||
with open(output, "w") as output: | ||
output.write('\n'.join(emojis)) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description='Emoji list retriever from unicode website') | ||
|
||
parser.add_argument('--url', type=str, default="http://unicode.org/emoji/charts-12.0/full-emoji-list.html", | ||
help='Unicode website for emoji') | ||
parser.add_argument('--output', type=str, default='emojis.ini', | ||
help='Output file') | ||
|
||
args = parser.parse_args() | ||
|
||
get_emojis(args.url, args.output) |
Oops, something went wrong.