gpt4 book ai didi

python - 带有部分字符串的 xpath 搜索属性

转载 作者:太空宇宙 更新时间:2023-11-04 10:15:40 25 4
gpt4 key购买 nike

我正在搜索类似 find_element_by_xpath('//a[@href="/requirements/22"]')

的元素

我可以只搜索其中的一部分吗?我的意思是不是 /requirements/22*22?

最佳答案

包含:

find_element_by_xpath('//a[contains(@href, "22")]')

开始于:

find_element_by_xpath('//a[starts-with(@href, "22")]')

结束于:

find_element_by_xpath('//a[starts-with(@href, "22")]')

您也可以自由尝试组合,示例:find_element_by_xpath('//a[开始于(@href, "22") 并包含(@href, "req")]')

关于python - 带有部分字符串的 xpath 搜索属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35517437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com