python求助
  • 板块灌水区
  • 楼主yjh6666
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/12/16 14:20
  • 上次更新2023/12/16 16:13:16
查看原帖
python求助
1200008
yjh6666楼主2023/12/16 14:20

求助!谁知道这个代码什么意思?

import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from msedge.selenium_tools import Edge, EdgeOptions
from selenium.common.exceptions import WebDriverException

edge_options = EdgeOptions()
edge_options.use_chromium = True
msedge_path = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
edge_options.binary_location = msedge_path
edge_options.add_argument("--enable-chrome-browser-cloud-management")
#edge_options.add_argument("headless")

driver = Edge(executable_path=r'.\msedgedriver.exe', options=edge_options)
driver.get("https://chat18.aichatos.xyz/")
textarea = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.XPATH, '/html/body/div[1]/div/div[1]/div/div/div/div/div/div/footer/div/div[3]/div/div[1]/div[1]/textarea'))
)

i=2
while(1):
    textarea.send_keys(input("text:"))
    btn = driver.find_element_by_xpath('//*[@id="app"]/div/div[1]/div/div/div/div/div/div/footer/div/button')
    btn.click()
    xpath = '//*[@id="image-wrapper"]/div[' + str(i) + ']/div[2]/div/div[1]'
    stopxpath = '/html/body/div[1]/div/div[1]/div/div/div/div[2]/div/div/main/div/div/div[3]'
    element = WebDriverWait(driver, 10).until(
        EC.invisibility_of_element_located((By.XPATH, stopxpath))
    )
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.XPATH, xpath))
    )
    print(element.text)
    i+=2
    
driver.quit()


2023/12/16 14:20
加载中...