Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python XPath在scrapy中工作,但在selenium中不工作_Python_Selenium_Scrapy_Xpath - Fatal编程技术网

Python XPath在scrapy中工作,但在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,它可以在python scrapy和firefox的firebug扩展中使用。但是,它在python selenium中不起作用。我在selenium中使用的代码如下

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