Search code examples
pythonpython-3.xseleniumwhatsappemoji

selenium, how to get emoji from whatsapp chat messege and print that emoji in our terminal?


how to get emoji from whatsapp chat messege and send print that emoji in our terminal or save in a list (python) in selenium ? , i know how to get text messeges from whatsapp chats and print in our terminal or saved them as a list in python selenium . but that only works for text messages , code prints a blank (space) or sometimes a new line instead of emoji

chats = driver.find_elements_by_class_name("message-in") 
for i in range(0, len(chats)):
    text_messege = chats[i].find_element_by_class_name("i0jNr").text 
    print(f"{str(i)} : {text_messege}")

Solution

  • okay, so if you use

    img[data-plain-text][crossorigin='anonymous']
    

    css selector it will list all the emojis.

    chats = driver.find_elements_by_css_selector("img[data-plain-text][crossorigin='anonymous']")
    for chat in chats:
        print(chat.get_attribute('alt'))
    

    This should basically print all the emojis.