from selenium import webdriver
import time
from selenium.webdriver.common.by import By
wd = webdriver.Chrome()
url = 'https://zxjk.sthjt.zj.gov.cn/zxjk/'
wd.get(url)
wd.implicitly_wait(15)
#入河排污口
wd.find_element(By.XPATH,'/html/body/table/tbody/tr[2]/td/map/area[10]').click()
#切换到INDEX的iframe
wd.switch_to.frame('index')
#找到工厂列表
elements = wd.find_element(By.ID,'left_list').find_elements(By.TAG_NAME,'li')
for el in elements:
#输出工厂名
print(el.text)
counts = 0
#选择工厂
el.click()
#点击站点信息
# wd.find_element(By.XPATH,'//*[@id="TabSelect"]/ul/li[3]').click()
#进入站点信息查询框架
wd.switch_to.frame('StationFrame')
#通过JS解除禁止输入日期功能,输入日期并且下载数据
js1 = 'document.getElementById("begintime").removeAttribute("readonly")'
wd.execute_script(js1)
wd.find_element(By.XPATH,'/html/body/div[1]/div[1]/table/tbody/tr[1]/td[4]/input[1]').clear()
wd.find_element(By.XPATH,'/html/body/div[1]/div[1]/table/tbody/tr[1]/td[4]/input[1]').send_keys('201501010')
wd.find_element(By.XPATH,'//*[@id="getInfoBtn"]').click()
wd.switch_to.alert.accept()
table = wd.find_element(By.XPATH,'//*[@id="FHeader"]/tbody').text
print(table)
time.sleep(5)
#返回 id为INDEX的iframe框架,方便下次遍历
wd.switch_to.default_content()
wd.switch_to.frame('index')
File "C:\Users\bigfly\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: 您选择的时间段在90天以上,查询所需时间可能较长,确定查询?
Message: unexpected alert open: {Alert text : 您选择的时间段在90天以上,查询所需时间可能较长,确定查询?}
(Session info: chrome=111.0.5563.65)
Stacktrace:
请问这种情况如何修改?