关于selenium定位的问题
本帖最后由 xyh2695368537 于 2022-10-3 21:07 编辑如图,像这种定位文本’星期一‘,再点击它前面的框框,这种要怎么写 网站附上:http://ad.jxzyz.cn/vol/index.php/Home/Index/zc.html 代码附上吧 suchocolate 发表于 2022-10-3 21:07
代码附上吧
网址:http://ad.jxzyz.cn/vol/index.php/Home/Index/zc.html
{:10_266:}
我用的是
driver.find_element(By.XPATH,"//*[@id='form1']/dl/dd/span/input").click()
听说这种写法在很多地方不能用,想看看有没有其他写法 xyh2695368537 发表于 2022-10-3 21:23
网址:http://ad.jxzyz.cn/vol/index.php/Home/Index/zc.html
我用的是
贴就贴全部的代码,一般爬取都要用wait和expected。from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as expected
from selenium.webdriver.support.wait import WebDriverWait
if __name__ == "__main__":
driver = Firefox()
wait = WebDriverWait(driver, timeout=10)
driver.get('http://ad.jxzyz.cn/vol/index.php/Home/Index/zc.html')
ele = wait.until(
expected.visibility_of_element_located(
(By.XPATH, '//input')
)
)
ele.click()
页:
[1]