How to Automate Sending Snaps on Snapchat using Selenium and ChromeDriver
Introduction
In this article, we will learn how to automate sending snaps to your friends on Snapchat using Selenium and ChromeDriver. We will also discuss the precautions you need to take while automating Snapchat and how to download the appropriate version of ChromeDriver that is compatible with your Chrome browser version.
Prerequisites
To follow along with this tutorial, you will need:
- Python 3.x installed on your system
- Selenium package installed
- Chrome browser installed on your system
Downloading ChromeDriver
To Download ChromeDriver On Replit Run The Following Code In Shell
!pip install chromedriver-binary-auto
To download the appropriate version of ChromeDriver that is compatible with your Chrome browser version, you can visit the Chrome for Testing availability dashboard. If you are using Selenium version 4.12.0 or higher, you do not have to worry about downloading the ChromeDriver manually, as Selenium's new in-built tool Selenium Manager will download and manage the drivers for you automatically.
Main Code
Here is the main code to start sending snaps:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service()
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
driver.get("https://www.snapchat.com/")
# Login to Snapchat
username = input("Enter your username: ")
password = input("Enter your password: ")
username_field = driver.find_element_by_name("username")
password_field = driver.find_element_by_name("password")
username_field.send_keys(username)
password_field.send_keys(password)
driver.find_element_by_xpath("//button[contains(text(), 'Log In')]").click()
# Send snaps to friends
friends = ["friend1", "friend2", "friend3"]
for friend in friends:
driver.find_element_by_xpath("//span[contains(text(), 'Chats')]").click()
driver.find_element_by_xpath(f"//span[contains(text(), '{friend}')]").click()
driver.find_element_by_xpath("//button[contains(text(), 'Send')]").click()
Please note that automating Snapchat is against their terms of service and can lead to your account being banned. It is recommended that you use Snapchat only through their official app.

0 Comments