File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Python Script to check who is Online on WhatsApp using Selenium
2
+
3
+ ## Steps to use script:
4
+
5
+ 1. Clone the Repo
6
+ 2. In the users.py file update the username of the contacts
7
+ 3. Run $ python3 who_is_online_on_whatsapp.py
8
+
9
+ ## OUTPUT:
10
+
11
+ ![ ] ( https://snipboard.io/mzZ4IG.jpg )
Original file line number Diff line number Diff line change
1
+ from selenium .webdriver .common .keys import Keys
2
+ from selenium .common .exceptions import NoSuchElementException
3
+ from selenium import webdriver
4
+ from selenium .webdriver .support .ui import WebDriverWait
5
+ import time
6
+ import users
7
+
8
+
9
+ def checkStatus ():
10
+ try :
11
+ browser .find_element_by_xpath (
12
+ "/html/body/div[1]/div/div/div[4]/div/header/div[2]/div[2]/span"
13
+ )
14
+ except NoSuchElementException :
15
+ return False
16
+ return True
17
+
18
+
19
+ NEWCHAT = "/html/body/div[1]/div/div/div[3]/div/header/div[2]/div/span/div[2]/div/span"
20
+ SEARCH = "/html/body/div[1]/div/div/div[2]/div[1]/span/div/span/div/div[1]/div/label/div/div[2]"
21
+ USER = "/html/body/div[1]/div/div/div[2]/div[1]/span/div/span/div/div[2]/div[1]/div/div/div[2]/div/div"
22
+ ONLINE = "/html/body/div[1]/div/div/div[4]/div/header/div[2]/div[2]/span"
23
+
24
+ browser = webdriver .Chrome (executable_path = r"/Users/sanketwable/downloads/chromedriver" )
25
+ browser .get ("https://web.whatsapp.com/" )
26
+
27
+ print ("Loading..\n " )
28
+
29
+ wait = WebDriverWait (browser , 600 )
30
+ time .sleep (10 )
31
+
32
+ for user_name in users .USERS :
33
+
34
+ newchat = browser .find_element_by_xpath (NEWCHAT )
35
+ newchat .click ()
36
+ search = browser .find_element_by_xpath (SEARCH )
37
+ search .send_keys (user_name )
38
+ time .sleep (2 )
39
+
40
+ user = browser .find_element_by_xpath ('//span[@title="{}"]' .format (user_name ))
41
+ user .click ()
42
+
43
+ time .sleep (2 )
44
+
45
+ if checkStatus ():
46
+ print (user_name )
47
+ print ("is online\n " )
48
+ else :
49
+ print (user_name )
50
+ print ("is offline\n " )
51
+
52
+
53
+ print ("Done checking WhatsApp online Status" )
Original file line number Diff line number Diff line change
1
+ USERS = [
2
+ "Mummy jio" ,
3
+ "didi vodafone" ,
4
+ "Abhay Nit Mec" ,
5
+ "dad jio" ,
6
+ "Jiofi" ,
7
+ "Dhanesh Kothavale" ,
8
+ "Pravin Kardile" ,
9
+ "Harry cse" ,
10
+ "Nipun Nitkkr It" ,
11
+ ]
You can’t perform that action at this time.
0 commit comments