-3
Xpath无法在Google Chrome中使用。Xpath无法正常工作Google Chrome for Xml Document Scrapy Python
$ X( '// URL')
回报= []#空
$ X('// DIV [@ ID = “WebKit的XML的观察者源-XML”] “)
收益= [] #Empty
<div xmlns="http://www.w3.org/1999/xhtml" id="webkit-xml-viewer-source-xml">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.sample.co.uk/</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.sample1.co.uk/motherboardbundles/</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.sample2.co.uk/barebonebundles/</loc>
<changefreq>daily</changefreq>
</url>
</urlset></div>
请告诉我什么是错我的XPath。 任何帮助将不胜感激。
感谢 Syyed
对于xpath请参见下文。
你可以看到,当我在开发人员工具(谷歌浏览器)中使用Xpath时,我得到NULL(空)。
你必须告诉我们更多关于如何在文档上运行XPath(即显示一些代码) –
''// url''意味着没有命名空间的url,但是您似乎使用了命名空间。您也需要在XPath表达式中指定它。 – choroba
您可以阅读关于Scrapy选择器和XML命名空间[这里](https://docs.scrapy.org/en/latest/topics/selectors.html#removing-namespaces)和[here](https://parsel.readthedocs .IO/EN /最新/ usage.html中#特设的命名空间引用)。 –