1

I am a beginner in this.

I want to send a WhatsApp message to multiple users using web browser module (and not selenium). I have written the following code:

import webbrowser

msg = input('Enter a Message: ')
number = input('Enter contact number: ')

number = number.split(',')

for i in number:
    web = webbrowser.open_new_tab(f'https://web.whatsapp.com/send?phone=+91{i}&text={msg}')

I know this is not the best approach as it opens up a WhatsApp tab as many as the total contact number entered by the user and I have to manually hit the send button each time in every tab.

Is there any better way than this?

Thanks in Advance

Harsh Dhamecha
  • 116
  • 3
  • 12

1 Answers1

1

It's pretty simple. You just need to tell Python to press enter for you. That can be done using pyautogui library.

See this code:

import pyautogui as pg
pg.press("Enter")

Now you are good to go.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253