Selenium WebScraper for WhatsApp to atomatically add People in Group

This page summarizes the projects mentioned and recommended in the original post on /r/learnpython

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • SendWhatsppTextByJavaScript

    Here is small JS Script for sending a message in a loop.

  • def __init__(self, group_name=GN): self.group_name = group_name logging.info("Starting WhatsAppGroupManager") options = webdriver.ChromeOptions() options.add_argument("user-data-dir=" + PATH_TO_CHROME_DRIVER_USER_PROFILE) self.driver = webdriver.Chrome(options=options) # self.driver.maximize_window() self.driver.get('https://web.whatsapp.com/') logging.info("Opened WhatsApp Web") def manager_kill(self): self.driver.close() self.driver.quit() def open_group_chat(self): try: # Wait for the chat input field to be visible chat_input = WebDriverWait(self.driver,45).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/div[2]/div[3]/div/div[1]/div/div[2]/div[2]/div/div[1]/p') ) ) time.sleep(sleep_time) chat_input.click() Logger.info("Clicked on the chat input field on the left side of WhatsApp") time.sleep(sleep_time) # Find the input field again after clicking on it chat_input = WebDriverWait(self.driver, 45).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/div[2]/div[3]/div/div[1]/div/div[2]/div[2]/div/div[1]/p') ) ) chat_input.send_keys(self.group_name) Logger.info("Inserted the group name into the search field") time.sleep(sleep_time) chat_input.send_keys(Keys.ENTER) Logger.info("Pressed ENTER") time.sleep(sleep_time) Logger.info("Opened the group chat") except Exception as e: Logger.error(f"Error: {e}") self.manager_kill() return None def open_group_info(self): try: # open group chat self.open_group_chat() time.sleep(sleep_time) chat_input = WebDriverWait(self.driver, 45).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/div[2]/div[4]/div/header/div[3]/div/div[3]/div/div/span') ) ) chat_input.click() Logger.info("Clicked on the group info button") time.sleep(sleep_time) # Find the input field again after clicking on it chat_input = WebDriverWait(self.driver, 45).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/span[5]/div/ul/div/div/li[1]/div') ) ) chat_input.click() Logger.info("In group info menu") time.sleep(sleep_time) except Exception as e: logging.error(f"Error in open_group_info: {e}") self.manager_kill() return None def open_add_telephone_numbers(self): self.open_group_info() time.sleep(sleep_time) try: chat_input = WebDriverWait(self.driver, 45).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/div[2]/div[5]/span/div/span/div/div/div/section/div[7]/div[2]/div[1]/div[2]/div/div') ) ) chat_input.click() Logger.info("Clicked on the add telephone numbers button") time.sleep(sleep_time) except Exception as e: logging.error(f"Error in open_add_telephone_numbers: {e}") self.manager_kill() return None def add_telephone_numbers(self, phone_numbers): if isinstance(phone_numbers, str): phone_numbers = [phone_numbers] # convert string to list self.open_add_telephone_numbers() time.sleep(sleep_time) try: for phone_number in phone_numbers: try: chat_input = WebDriverWait(self.driver, 45).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div/div[1]/div/div[2]/div[2]/div/div[1]/p') ) ) chat_input.click() Logger.info("Clicked on the search field") time.sleep(sleep_time) # Clear the text field chat_input.send_keys(Keys.CONTROL + 'a') chat_input.send_keys(Keys.DELETE) chat_input.send_keys(phone_number) Logger.info("Inserted the phone number into the search field") time.sleep(sleep_time) # Check if the phone number exists # Not Working try: WebDriverWait(self.driver, 2).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div/div[2]/div/div/div/div[2]/div/div[2]') ) ) Logger.info("Phone Number exist") time.sleep(sleep_time) # Send the ENTER key chat_input.send_keys(Keys.ENTER) Logger.info("Pressed ENTER to add the person into the group") time.sleep(sleep_time) continue except: Logger.info(f"Phone number does not exists: {phone_number}") time.sleep(sleep_time) pass except Exception as e: logging.error(f"Error in open_add_telephone_numbers: {e}") self.manager_kill() return None # Send the ENTER key chat_input.send_keys(Keys.ENTER) Logger.info("Pressed ENTER to add the person into the group") time.sleep(sleep_time) chat_input = WebDriverWait(self.driver, 45).until(EC.visibility_of_element_located( ( By.XPATH, '/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div/span[2]/div/div/div/span') ) ) chat_input.click() Logger.info("Clicked on the add telephone numbers button") time.sleep(sleep_time) # Confirm the adding of the telephone numbers chat_input = WebDriverWait(self.driver, 45).until(EC.element_to_be_clickable( ( By.XPATH, '/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button[2]/div/div') ) ) time.sleep(5) Logger.info("Should click on the confirmation the add telephone numbers button") chat_input.click() Logger.info("Clicked on Confirmation the add telephone numbers button") time.sleep(4) except Exception as e: logging.error(f"Error in add_telephone_numbers: {e}") self.manager_kill() return None

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Integration Testing in Obsidian

    3 projects | dev.to | 2 May 2024
  • A Lawsuit Argues Meta Is Required by Law to Let You Control Your Own Feed

    2 projects | news.ycombinator.com | 2 May 2024
  • Unemployed: I spent the past month building AWS S3 from bare-metal

    1 project | news.ycombinator.com | 2 May 2024
  • Understanding Nginx: From Simple Concepts to Technical Details and Deploying securely with PM2 and Certbot

    1 project | dev.to | 2 May 2024
  • Show HN: An extension to track your Wikipedia adventures

    3 projects | news.ycombinator.com | 2 May 2024