Привет, пытаюсь зарегистрировать аккаунт в инстаграм с помощью seleniumwire
До этого использовать selenium и с кликами на кнопки все было ок, но как только перешел на seleniumwire, скрипт не хочет нажимать на кнопки
Вот мой код:
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options as chromeOptions
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from fake_useragent import UserAgent
import accountInfoGenerator as account
import getVerifCode as verifiCode
from seleniumwire import webdriver
import fakeMail as email
import time
import argparse
import json
import requests
accNo = int(input("Кол-во аккаунтов для создания: "))
options = {
'proxy': {
'http': 'proxy',
'https': 'proxy',
'no_proxy': 'localhost,127.0.0.1' # excludes
}
}
chrome_options = chromeOptions()
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument('--log-level=2')
driver = webdriver.Chrome(ChromeDriverManager().install(), seleniumwire_options=options, chrome_options=chrome_options)
for i in range(accNo):
driver.get("https://www.instagram.com/accounts/emailsignup/")
time.sleep(8)
try:
cookie = driver.find_element_by_xpath('/html/body/div[2]/div/div/div/div[2]/button[1]').click()
except:
pass
name = account.username()
#Fill the email value
token = '123' # токен от сервиса почт
url = f'http://api.kopeechka.store/mailbox-get-email?site=instagram.com&mail_type=ALL&token={token}&no_search=1&api=2.0'
r = requests.get(url)
if r.status_code == 200:
a = json.loads(r.content)
print(a)
ids = a['id']
fake_email = a['mail']
email_field = driver.find_element_by_name('emailOrPhone')
email_field.send_keys(fake_email)
print(fake_email)
with open('femail.txt', 'a', encoding='utf8') as f:
f.write(str(fake_email) + "\n")
# Fill the fullname value
fullname_field = driver.find_element_by_name('fullName')
fullname_field.send_keys(account.generatingName())
fname = account.generatingName()
print(fname)
with open('fullname.txt', 'a', encoding='utf8') as f:
f.write(fname + "\n")
# Fill username value
username_field = driver.find_element_by_name('username')
username_field.send_keys(name)
print(name)
with open('username.txt', 'a', encoding='utf8') as f:
f.write(name + "\n")
# Fill password value
password_field = driver.find_element_by_name('password')
password_field.send_keys(account.generatePassword()) # You can determine another password here.
passw = account.generatePassword()
print(passw)
with open('password.txt', 'a', encoding='utf8') as f:
f.write(passw + "\n")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='react-root']/section/main/div/div/div[1]/div/form/div[7]/div/button"))).click() # не кликает на кнопку регистрация
time.sleep(8)
#Birthday verification
driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[1]/select").click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[1]/select/option[4]"))).click()
driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[2]/select").click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[2]/select/option[10]"))).click()
driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[3]/select").click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[3]/select/option[27]"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='react-root']/section/main/div/div/div[1]/div/div[6]/button"))).click()
time.sleep(3)
#
uri = f'http://api.kopeechka.store/mailbox-get-message?id={ids}&token={token}&api=2.0'
r = requests.get(uri)
if r.status_code == 200:
d = json.loads(r.content)
print(d)
val = d['value']
while val == 'WAIT_LINK':
r = requests.get(uri)
if r.status_code == 200:
d = json.loads(r.content)
val = d['value']
print(val)
print('yeah, code is', val)
instCode = val
driver.find_element_by_name('email_confirmation_code').send_keys(instCode, Keys.ENTER)
time.sleep(10)
try:
not_valid = driver.find_element_by_xpath('/html/body/div[1]/section/main/div/div/div[1]/div[2]/form/div/div[4]/div')
if(not_valid.text == 'That code isn\'t valid. You can request a new one.'):
time.sleep(1)
driver.find_element_by_xpath('/html/body/div[1]/section/main/div/div/div[1]/div[1]/div[2]/div/button').click()
time.sleep(10)
uri = f'http://api.kopeechka.store/mailbox-get-message?id={ids}&token={token}&api=2.0'
r = requests.get(uri)
if r.status_code == 200:
d = json.loads(r.content)
print(d)
val = d['value']
while val == 'WAIT_LINK':
r = requests.get(uri)
if r.status_code == 200:
d = json.loads(r.content)
val = d['value']
print(val)
print('yeah, code is', val)
confInput = driver.find_element_by_name('email_confirmation_code')
confInput.send_keys(Keys.CONTROL + "a")
confInput.send_keys(Keys.DELETE)
confInput.send_keys(val, Keys.ENTER)
except:
pass
# Ошибка:
Traceback (most recent call last):
File "c:/Users/User/Desktop/instagram-auto-create-account-master/botAccountCreate.py", line 86, in <module>
driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[1]/select").click()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='react-root']/section/main/div/div/div[1]/div/div[4]/div/div/span/span[1]/select"}
(Session info: chrome=88.0.4324.104)