url = 'https://emojigraph.org/people-body'
response = requests.get(url).text.encode('utf-8')
response = BeautifulSoup(response, 'html.parser')
div_contents = response.find('h2', text='Person').findParent()
big_urls = []
for link in div_contents.findAll('a'):
tail = str(link.get('href'))
big_urls.append('https://emojigraph.org'+tail)
small_urls = []
for l in range(len(big_urls)):
res = requests.get(big_urls[l]).text.encode('utf-8')
res = BeautifulSoup(res, 'html.parser')
for ul in res.find_all("ul", {'class':'emoji__ul diversity'})[0]:
ttail = re.findall('(?<=href=")(.*?)(?=")', str(ul))
try:
small_urls.append("https://emojigraph.org"+ttail[0])
except:
pass
n = 0
for tone in list(set(small_urls) - set(big_urls)): # 노란 피부는 제외
tone = requests.get(tone).text.encode('utf-8')
tone = BeautifulSoup(tone, 'html.parser')
for apple in tone.findAll("img"):
if 'apple' in str(apple):
source = re.findall('(?<=data-src=")(.*?)(?=")', str(apple))
source = "https://emojigraph.org"+source[0]
res = urllib.request.urlopen(source).read()
# urllib.request.urlretrieve(source, "./ios_emoji/emoji_%03d.png" % n)
img = Image.open(BytesIO(res))
img = img.convert('RGBA')
white = square_and_fill(img)
white = white.convert('RGB')
white = white.resize((256, 256))
white.save("./ios_emoji/emoji_%03d.png" % n)
n += 1
'컴퓨터 > python' 카테고리의 다른 글
파이썬의 비동기 처리 (0) | 2022.05.23 |
---|---|
[python] M1 opencv 설치하기 (0) | 2021.09.02 |
[python] 문자열 타입으로 된 리스트를 리스트 타입으로 바꾸기 (0) | 2021.08.07 |
[파이썬] pyinstaller exe파일 에러 (0) | 2021.04.14 |
[Python] 객체와 return (0) | 2021.03.09 |