Python XPath在scrapy中工作,但在selenium中不工作
我有一个xpath,它可以在python scrapy和firefox的firebug扩展中使用。但是,它在python selenium中不起作用。我在selenium中使用的代码如下Python XPath在scrapy中工作,但在selenium中不工作,python,selenium,scrapy,xpath,Python,Selenium,Scrapy,Xpath,我有一个xpath,它可以在python scrapy和firefox的firebug扩展中使用。但是,它在python selenium中不起作用。我在selenium中使用的代码如下 xpath = ".//div[@id='containeriso3']/div/a[1]/@href" browser.find_element_by_xpath(xpath) 这会产生InvalidSelectorException错误。selenium是否使用了其他xpath版本?这不会为您提供元素。您
xpath = ".//div[@id='containeriso3']/div/a[1]/@href"
browser.find_element_by_xpath(xpath)
这会产生InvalidSelectorException错误。selenium是否使用了其他xpath版本?这不会为您提供元素。您需要关闭
@href
属性
使用//div[@id='containeriso3']/div/a[1]
然后使用
get_属性
从中获取href
。这不会获取元素。您需要关闭@href
属性
使用//div[@id='containeriso3']/div/a[1]
然后使用get_属性
从中获取href