zhegexiaohuozi/JsoupXpath

//*[text()="总字数"]//text()这种规则报错

gedoor opened this issue · 3 comments

Please answer these questions before submitting your issue. Thanks!

  1. What did you do , If possible, provide a recipe for reproducing the error.(使用的表达式与使用场景,确保能够复现)?
    //*[text()="总字数"]//text(),2.4.2这种规则会抛出错误,2.3.2正常
<li class="res-book-item" data-bid="1018351389" data-rid="1"> 
 <div class="book-img-box"> <a href="//book.qidian.com/info/1018351389" target="_blank" data-eid="qd_S04" data-algrid="0.0.0" data-bid="1018351389"><img src="//bookcover.yuewen.com/qdbimg/349573/1018351389/150"></a> 
 </div> 
 <div class="book-mid-info"> 
  <h4><a href="//book.qidian.com/info/1018351389" target="_blank" data-eid="qd_S05" data-bid="1018351389" data-algrid="0.0.0"><cite class="red-kw">我们</cite>平凡<cite class="red-kw">我们</cite>忠诚</a></h4> 
  <p class="author"> <img src="//qidian.gtimg.com/qd/images/ico/user.f22d3.png"><a class="name" data-eid="qd_S06" href="//my.qidian.com/author/403791004" target="_blank">巡璃</a> <em>|</em><a href="//www.qidian.com/duanpian" data-eid="qd_S07" target="_blank">短篇</a><em>|</em><span>连载</span> </p> 
  <p class="intro"> 这是一位普通老兵的故事,这位老兵没有走上战场,也没有人歌颂他,但他的工作却是面对生与死,他是一名普通的军转干部,没有得到任何荣誉,却仍旧坚守着信仰,永远忠诚。除了他的家人,他的战友,他的故事不被任何人所知,但他的故事正是一代军人、一代军转干部的写照。所以,我来歌颂他,歌颂那一代人。 </p> 
  <p class="update"><a href="//read.qidian.com/chapter/YiObT_DmJpXu4xLcYRGW6w2/Ulsr6ThvJS5p4rPq4Fd4KQ2" target="_blank" data-eid="qd_S08" data-bid="1018351389" data-cid="//read.qidian.com/chapter/YiObT_DmJpXu4xLcYRGW6w2/Ulsr6ThvJS5p4rPq4Fd4KQ2">最新更新 第一次见识到生死</a><em>·</em><span>2020-02-19</span> </p> 
 </div> 
 <div class="book-right-info"> 
  <div class="total"> 
   <p><span> 4497</span>总字数</p> 
   <p><span> 0</span>总推荐</p> 
  </div> 
  <p class="btn"> <a class="red-btn" href="//book.qidian.com/info/1018351389" data-eid="qd_S02" target="_blank">书籍详情</a> <a class="blue-btn add-book" href="javascript:" data-eid="qd_S03" data-bookid="1018351389" data-bid="1018351389">加入书架</a> </p> 
 </div> </li>
  1. What did you expect to see(期望看到什么)?
    4497
  2. What did you see instead(JsoupXpath给出的结果)?
    W/System.err: org.seimicrawler.xpath.exception.XpathSyntaxErrorException: Please check the syntax of your xpath expr or commit a NullPointerException: Attempt to invoke virtual method 'boolean org.jsoup.nodes.Element.isBlock()' on a null object reference
    W/System.err: at org.seimicrawler.xpath.JXDocument.selN(JXDocument.java:128)
  3. What version of JsoupXpath are you using(当前版本)?
    2.4.2

text()重构后文本比对逻辑没有同步更新导致的。2.4.3已修复。JsoupXpath表现行为和Xpath1.0标准语法以及Chrome的实现保持一致。Chrome的实现可以通过 $x("//*[text()='总字数']//text()")来验证。JsoupXpath的test如下:

text()重构后文本比对逻辑没有同步更新导致的。2.4.3已修复。JsoupXpath表现行为和Xpath1.0标准语法以及Chrome的实现保持一致。Chrome的实现可以通过 $x("//*[text()='总字数']//text()")来验证。JsoupXpath的test如下:

还是报错
W/System.err: java.lang.NoSuchMethodError: No direct method (Lorg/jsoup/select/NodeVisitor;)V in class Lorg/jsoup/select/NodeTraversor; or its super classes (declaration of 'org.jsoup.select.NodeTraversor' appears in /data/app/~~s7_CEtBTLvnrVyLXmyMu3g==/io.legado.app.debug-Fr4yRYoACSlWuprA164Txg==/base.apk!classes3.dex)
at org.seimicrawler.xpath.core.node.Text.call(Text.java:54)
W/System.err: at org.seimicrawler.xpath.core.XpathProcessor.visitNodeTest(XpathProcessor.java:220)
at org.seimicrawler.xpath.core.XpathProcessor.visitNodeTest(XpathProcessor.java:31)
at org.seimicrawler.xpath.antlr.XpathParser$NodeTestContext.accept(XpathParser.java:558)
W/System.err: at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
at org.seimicrawler.xpath.core.XpathProcessor.visitStep(XpathProcessor.java:102)
W/System.err: at org.seimicrawler.xpath.core.XpathProcessor.visitStep(XpathProcessor.java:31)
at org.seimicrawler.xpath.antlr.XpathParser$StepContext.accept(XpathParser.java:404)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
W/System.err: at org.seimicrawler.xpath.core.XpathProcessor.visitRelativeLocationPath(XpathProcessor.java:68)
at org.seimicrawler.xpath.core.XpathProcessor.visitRelativeLocationPath(XpathProcessor.java:31)

//[text()="总字数"]//text() 可以获取正确结果
//
[text()="总字数"]//text()[0] 获取不到结果