我正在运行一个脚本来登录网站并提取信息以实现卓越。
它曾经可以平稳,快速地运行,但现在只有SLOW和SLOW。运行.click()
方法花了15秒,而只花了2秒。我想知道产生如此低效结果的代码有什么问题吗?此外,我的excel文件已损坏,无法在运行脚本后打开。任何帮助将不胜感激。
from selenium import webdriver
import XLUtlis
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome("C:\Users\XUPJ21WJH\Desktop\Testing\Drivers\chromedriver.exe")
driver.get("https://cmis2.cat.com/cmis_tc/Main.jsp?selectedURL=/CoreInquiry")
driver.maximize_window()
driver.find_element_by_name("cwsUID").send_keys("J1W")
driver.find_element_by_name("cwsPwd").send_keys("")
driver.find_element_by_id("submitButton").send_keys(Keys.ENTER)
path = "C://Users/XUPJ21WJH/Desktop/test.xlsx"
row = XLUtlis.getRowCount(path, 'Sheet1')
for r in range(2, row + 1):
j19r = XLUtlis.readData(path, 'Sheet1', r, 1)
driver.find_element_by_name("CcrNo").send_keys(j19r)
driver.find_element_by_name("Search").click()
driver.find_element_by_css_selector("#main_screen > form > table:nth-child(5) > tbody > tr.tableBodyOdd > td:nth-child(1) > table > tbody > tr > td:nth-child(1) > a > img").click()
driver.find_element_by_xpath("//a[@href='Main.jsp?selectedURL=/CCRViewCredit']").click()
number = driver.find_element_by_xpath("//tr[@class = 'tableBodyOdd']/td[position() = last() -1]").text
XLUtlis.writeData(path, 'Sheet1', r, 3, number)
driver.find_element_by_css_selector("#main_screen > form > div:nth-child(5) > table:nth-child(2) > tbody > tr > td > p > input[type=submit]:nth-child(1)").click()
driver.find_element_by_css_selector("#main_screen > div > form > div:nth-child(6) > table:nth-child(10) > tbody > tr > td > input[type=SUBMIT]:nth-child(3)").click()
driver.find_element_by_css_selector("#main_screen > form > center:nth-child(7) > input").click()