|
楼主 |
发表于 2023-4-25 10:46:26
|
显示全部楼层
谢谢!我刚才用很笨的方法实现了,很臃肿,看完您的解答,我觉得收获很多,并学习新方法去修改原来的代码,感谢!
def minhpcure():
driver.execute_script('useCut(2);return false;')
sleep(1.3)
global one,two,three,four,five
for i in range(1,6):
try:
match i:
case 1:
try:
in1 = driver.find_element(By.XPATH,f'/html/body/mw[2]/con/table/tbody/tr[{i}]/td[2]').get_attribute('textContent')
in1 = in1[0:in1.rfind('/'):]
one=eval(in1)
except:one=10000
case 2:
try:
in1 = driver.find_element(By.XPATH,f'/html/body/mw[2]/con/table/tbody/tr[{i}]/td[2]').get_attribute('textContent')
in1 = in1[0:in1.rfind('/'):]
one = eval(in1)
two=eval(in1)
except:two=10000
case 3:
try:
in1 = driver.find_element(By.XPATH,f'/html/body/mw[2]/con/table/tbody/tr[{i}]/td[2]').get_attribute('textContent')
in1 = in1[0:in1.rfind('/'):]
one = eval(in1)
three = eval(in1)
except:
three = 10000
case 4:
try:
in1 = driver.find_element(By.XPATH,f'/html/body/mw[2]/con/table/tbody/tr[{i}]/td[2]').get_attribute('textContent')
in1 = in1[0:in1.rfind('/'):]
one = eval(in1)
four = eval(in1)
except:
four = 10000
case 5:
try:
in1 = driver.find_element(By.XPATH,f'/html/body/mw[2]/con/table/tbody/tr[{i}]/td[2]').get_attribute('textContent')
in1 = in1[0:in1.rfind('/'):]
one = eval(in1)
five=eval(in1)
except:five = 10000
except:pass
def zhiliaomin():
if one==min(one,two,three,four,five):
try:
a=driver.find_element(By.XPATH, f'/html/body/mw[2]/con/table/tbody/tr[1]').get_attribute('onclick')
driver.execute_script(f'{a}')
bskill()
except:pass
elif two==min(one,two,three,four,five):
try:
a=driver.find_element(By.XPATH, f'/html/body/mw[2]/con/table/tbody/tr[2]').get_attribute('onclick')
driver.execute_script(f'{a}')
bskill()
except:pass
elif three==min(one,two,three,four,five):
try:
a = driver.find_element(By.XPATH, f'/html/body/mw[2]/con/table/tbody/tr[3]').get_attribute('onclick')
driver.execute_script(f'{a}')
bskill()
except:pass
elif four == min(one, two, three, four, five):
try:
a = driver.find_element(By.XPATH, f'/html/body/mw[2]/con/table/tbody/tr[4]').get_attribute('onclick')
driver.execute_script(f'{a}')
bskill()
except:pass
elif five == min(one, two, three, four, five):
try:
a = driver.find_element(By.XPATH, f'/html/body/mw[2]/con/table/tbody/tr[5]').get_attribute('onclick')
driver.execute_script(f'{a}')
bskill()
except:pass |
|