相信玩过爬虫的都知道一些库,如lxml(python),可以使用xpath方便地对HTML进行提取,但当真正用的时候,问题就来了,想找到一个元素往往要调试好几遍,而且得先code,下面提供了几个工具及如何用chrome进行xpath test
1.chrome xpath helper
chrome xpath插件下载 :https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl
Python1. Open a new tab and navigate to your favorite webpage. 2. Hit Ctrl-Shift-X to open the XPath Helper console. 3. Hold down Shift as you mouse over elements on the page. The query box will continuously update to show the full XPath query for the element below the mouse pointer. The results box to its right will show the evaluated results for the query. 4. If desired, edit the XPath query directly in the console. The results box will immediately reflect any changes. 5. Hit Ctrl-Shift-X again to close the console.
12345 1. Open a new tab and navigate to your favorite webpage .2. Hit Ctrl - Shift - X to open the XPath Helper console .3. Hold down Shift as you mouse over elements on the page . The query box will continuously update to show the full XPath query for the element below the mouse pointer . The results box to its right will show the evaluated results for the query .4. If desired , edit the XPath query directly in the console . The results box will immediately reflect any changes .5. Hit Ctrl - Shift - X again to close the console .
2.chrome xpathFinder – xpath查找助手
chrome xpath插件下载 https://chrome.google.com/webstore/detail/xpath-finder/ijaobnmmgonppmablhldddpfmgpklbfh/related
Python在chrome开发者工具里增加一个面板,帮助你快速查找匹配XPATH表达式的元素。 1. 匹配的节点会用红色边框突出显示。 2. 在结果列表里可以直接inspect对应节点。 3. 记录XPATH查找历史,方便查看历史。
12345 在 chrome开发者工具里增加一个面板,帮助你快速查找匹配 XPATH表达式的元素。1. 匹配的节点会用红色边框突出显示。2. 在结果列表里可以直接 inspect对应节点。3. 记录 XPATH查找历史,方便查看历史。3.chrome console xpath
F12->$x("//title")
[<title>Online Tools for Software Developers (Free)</title>]
7万+

被折叠的 条评论
为什么被折叠?



