XPath在scrapy中有效,但在selenium中无效。

2024-10-03 06:26:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个xpath,可以在pythonscrapy和firefox的firebug扩展中使用。但是,它在python-selenium中不起作用。我在selenium中使用的代码是

xpath = ".//div[@id='containeriso3']/div/a[1]/@href"
browser.find_element_by_xpath(xpath)

这将产生InvalidSelectorException错误。selenium是否使用其他xpath版本?在


Tags: 代码divbrowseridbyseleniumelementfind