I'm trying to make a spam dm Instagram bot
I just get this error
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element
I just want it to work in headless mode and here is my code
when I use a non-headless mode it just works I don't really know why so please help me
there is more code but im just importing the error line code which is the first
driver.find_element_by_xpath
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from time import sleep
def instsspamdm():
user = input("Enter the username: ")
password = input("Enter tha password: ")
target = input("Target: ")
mess = input("Target message: ")
sleepTime = int(input("Sleep[sec]: "))
delay = float(input("Delay[sec]: "))
autoMode = input("Auto Mode[y/n]: ")
if autoMode == "y":
options = Options()
options.headless = True
driver = webdriver.Chrome(ChromeDriverManager().install(), options = options)
driver.get("https://instagram.com")
sleep(sleepTime)
driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[1]/div/label/input").send_keys(user) # Account Username
driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[2]/div/label/input")
.send_keys(password) # Account Password
driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[3]/button")
y = 1
while True:
driver.find_element_by_xpath("/html/body/div[1]/section/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div[2]/textarea")
.send_keys(mess)
driver.find_element_by_xpath("/html/body/div[1]/section/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div[3]/button")
.click()
x = "Done Spam: "
print(x, y)
y += 1
sleep(delay)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…