Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukhdev841 committed Oct 23, 2018
0 parents commit 22d8e8a
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Spam WhatsApp Contact

#### Run the command to Send Message

``` python whatsapp_sendmessage.py


#### Run the command to get Recent Chat Contacts

``` python whatsapp_contacts.py ```

#Vinay Somawat
Binary file added chromedriver
Binary file not shown.
26 changes: 26 additions & 0 deletions whatsapp_contacts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
import sys

# Replace below path with the absolute path
# to chromedriver in your computer
driver = webdriver.Chrome('./chromedriver')

driver.get("https://web.whatsapp.com/")
wait = WebDriverWait(driver, 600)


group_title = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.RLfQR")))

time.sleep(5)
for person in driver.find_elements_by_class_name('_2wP_Y'):
title = person.find_element_by_xpath('div/div/div[2]/div[1]/div[1]/span').text
#company = person.find_element_by_xpath('.//div[@class="company"]/a').text
print(title)



45 changes: 45 additions & 0 deletions whatsapp_search_contacts_send_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
import sys

# Replace below path with the absolute path
# to chromedriver in your computer

friends_lists = ['Manikandan PM','Akshay wd']

driver = webdriver.Chrome('../chromedriver')

driver.get("https://web.whatsapp.com/")
wait = WebDriverWait(driver, 600)

group_title = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.RLfQR")))
search = driver.find_elements_by_xpath('//*[@id="side"]/div[2]/div/label/input')[0]

for friend in friends_lists:
search.clear()
search.send_keys(friend)
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button._3Burg")))
time.sleep(3)
persons = driver.find_elements_by_class_name('_2wP_Y')
print(len(persons))
for person in persons:
try:
if person.text not in ['CHATS','MESSAGES']:
person_title = person.find_element_by_class_name('_1wjpf')
print(person_title.get_attribute("title"))
person_contact = person.find_element_by_class_name('_2EXPL')
person_contact.click()
message = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')[0]
message.send_keys("This is Testing Message from Selenium")

sendbutton = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[3]/button')[0]
sendbutton.click()
except:
print("*")
continue

driver.close()
38 changes: 38 additions & 0 deletions whatsapp_sendmessage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
import sys

# Replace below path with the absolute path
# to chromedriver in your computer
driver = webdriver.Chrome('./chromedriver')

driver.get("https://web.whatsapp.com/")
wait = WebDriverWait(driver, 600)

# Replace 'Friend's Name' with the name of your friend
# or the name of a group
target = '"Tharkie"'

# Replace the below string with your own message
string = "I am sad!"

x_arg = '//span[contains(@title,' + target + ')]'
group_title = wait.until(EC.presence_of_element_located((
By.XPATH, x_arg)))
group_title.click()


message = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')[0]

for i in range(1000):
message.send_keys(string + Keys.ENTER)

sendbutton = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[3]/button')[0]
sendbutton.click()

driver.close()

0 comments on commit 22d8e8a

Please sign in to comment.