|
发表于 2022-10-3 17:59:46
|
显示全部楼层
本楼为最佳答案
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import Select as select
- import time
- drv=webdriver.Chrome(r"d:\python310\chromedriver.exe")
- drv.get("http://ad.jxzyz.cn/vol/index.php/Home/Index/zc.html")
- js = "document.getElementById('birthday').removeAttribute('readonly')"
- drv.execute_script(js)
- birthday = drv.find_element(By.ID,"birthday")
- birthday.send_keys('2022-10-03')
- s1=select(drv.find_element(By.XPATH,"//*[@id='form1']/dl[2]/dd[12]/table/tbody/tr/td[1]/select"))
- s1.select_by_visible_text("江西省")
- time.sleep(1)
- s2=select(drv.find_element(By.ID,"city"))
- s2.select_by_visible_text("抚州市")
- time.sleep(1) #如果网路延时大,这里可以加时
- s3=select(drv.find_element(By.ID,"area"))
- s3.select_by_visible_text("广昌县")
- time.sleep(1)
- s4=select(drv.find_element(By.ID,"town"))
- s4.select_by_visible_text("长桥乡")
复制代码 |
|