[Python] Check if WhatsApp number is registered without the API

Discussão em 'Python' iniciado por Stack, Outubro 23, 2024.

  1. Stack

    Stack Membro Participativo

    I want to write a program that checks whether the phone number that the user enters is registered in WhatsApp. I can't use the API.

    I tried to write the code and this is what I got. However, when you enter a number that is registered in WhatsApp, the console displays that the number is not registered.

    import phonenumbers
    from phonenumbers import carrier

    def is_whatsapp_number(phone_number):
    try:
    phone_number = phonenumbers.parse(phone_number)
    if phonenumbers.is_valid_number(phone_number):
    service_provider = carrier.name_for_number(phone_number, lang="EN")
    if "WhatsApp" in service_provider:
    return "YES"
    else:
    return "NO"
    else:
    return "Invalid phone number"
    except phonenumbers.phonenumberutil.NumberParseException:
    return "Invalid phone number"

    phone_number = input("Enter the phone number: ")
    result = is_whatsapp_number(phone_number)
    print(result)

    Continue reading...

Compartilhe esta Página