Convert xPath to JSoup query
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Does anyone know of an xPath to JSoup convertor? I get the following xPath from Chrome: //*[@id="docs"]/div[1]/h4/a and would like to change it into a Jsoup query. The path contains an href I'm trying to reference. 回答1: This is very easy to convert manually. Something like this (not tested) document.select("#docs > div:eq(1) > h4 > a").attr("href"); Documentation: http://jsoup.org/cookbook/extracting-data/selector-syntax Related question from comment Trying to get the href for the first result here: cbssports.com/info/search#q=fantasy%20tom