硒解析 https://myip.ms

Selenium parsing https://myip.ms

正在为 https://myip.ms 编写解析器我无法注册。我写了解析器会打开注册window,但是我不能输入任何数据,出现错误selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://myip.ms/#a")

button = driver.find_elements_by_xpath('//*[@id="fixed_width_page"]/table/tbody/tr/td/table[1]/tbody/tr/td[2]/div[2]/span[2]/a[1]')
if len(button) > 0:
    button[0].click()
driver.implicitly_wait(50)
print('Работает')

login = driver.find_element_by_xpath('/html/body/div[6]/div[2]/div/form/table/tbody/tr[1]/td[2]/span/input')
print('Работает 2')
time.sleep(10)

driver.implicitly_wait(50)
print(login)
if len(login) > 0:
    print('tut')
login.send_keys('фвыфы')

要将 字符序列 发送到 Email 字段,您需要引入 WebDriverWait for the and you can use either of the following :

  • 使用XPATH:

    driver.get("https://myip.ms/#a")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Login"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@aria-describedby='uidialog']//input[@id='email' and @name='email']"))).send_keys("Коля Нарушев")
    
  • 注意:您必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • 浏览器快照: