我正在搜索类似 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/