简体   繁体   English

python bot Instagram 电子邮件

[英]python bot Instagram Email

I am working on a Instagram account creator and I am stuck.我正在为 Instagram 帐户创建者工作,但我被困住了。 When you create an Instagram account you need an Email.创建 Instagram 帐户时,您需要一个电子邮件。 I am using ProtonMail and I am using Selenium to do my web automating but when I get to the step where it asks you to input the username you want, my code can't find the box.我正在使用 ProtonMail,我正在使用 Selenium 进行网络自动化,但是当我到达要求您输入所需用户名的步骤时,我的代码找不到该框。 Right now the code that selects the username box looks like this:现在选择用户名框的代码如下所示:

self.driver.find_element_by_id('username').send_keys(username)
self.driver.find_element_by_id('password').send_keys(password)
self.driver.find_element_by_id('passwordc').send_keys(password)

and the error looks like this:错误如下所示:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate 
element: {"method":"css selector","selector":"[id="username"]"}

but the id for the username is correct: id for username但用户名的 id 是正确的:用户名的 id

Also the two lines of code for passwords works, it is just the username that doesn't.密码的两行代码也有效,只是用户名无效。

I tried to find the username box by its class name but it doesn't work.我试图通过它的类名找到用户名框,但它不起作用。

For any future protonmail questions.对于任何未来的质子邮件问题。 It is a different iframe that is why the usual methods don't work.这是一个不同的iframe ,这就是为什么通常的方法不起作用。 We need to switch the iframe我们需要切换iframe

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("start-maximized")
    # chrome_options.add_argument('disable-infobars')
    driver = webdriver.Chrome(options=chrome_options, executable_path='C:/bin/chromedriver.exe')
    driver.get("https://protonmail.com/")
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='btn btn-default btn-short' and @href='signup']"))).click()
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='row']//p[text()='Basic account with limited features']"))).click()
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='btn btn-primary btn-lg pull-right' and @id='freePlan']"))).click()
    WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//div[@class='usernameWrap']//iframe[@title='Registration form']")))
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='input' and @id='username']"))).send_keys("username")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM