Published 2022. 8. 12. 10:00

🤦‍♀️ People & Body Emojis

 

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
복사했습니다!