Skip to content

Commit

Permalink
Merge branch 'update-dep'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
#	src/main/java/org/seimicrawler/xpath/core/node/Text.java
  • Loading branch information
wanghaomiao committed Jul 21, 2021
2 parents a5438e9 + 639ea24 commit 7bb89fc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
Expand All @@ -53,12 +53,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<version>1.7.25</version>
</dependency>
<!-- test -->
<dependency>
Expand Down Expand Up @@ -94,7 +89,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/seimicrawler/xpath/core/node/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/org/seimicrawler/xpath/JXDocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,33 @@ public void fixIssue53(){
Assert.assertEquals("总字数",l.get(1).asString());
}

@Test
public void fixIssue53B(){
String content = "<li class=\"res-book-item\" data-bid=\"1018351389\" data-rid=\"1\"> \n" +
" <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> \n" +
" </div> \n" +
" <div class=\"book-mid-info\"> \n" +
" <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> \n" +
" <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> \n" +
" <p class=\"intro\"> 这是一位普通老兵的故事,这位老兵没有走上战场,也没有人歌颂他,但他的工作却是面对生与死,他是一名普通的军转干部,没有得到任何荣誉,却仍旧坚守着信仰,永远忠诚。除了他的家人,他的战友,他的故事不被任何人所知,但他的故事正是一代军人、一代军转干部的写照。所以,我来歌颂他,歌颂那一代人。 </p> \n" +
" <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> \n" +
" </div> \n" +
" <div class=\"book-right-info\"> \n" +
" <div class=\"total\"> \n" +
" <p><span> 4497</span>总字数</p> \n" +
" <p><span> 0</span>总推荐</p> \n" +
" </div> \n" +
" <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> \n" +
" </div> </li>";
JXDocument j = JXDocument.create(content);
List<JXNode> l = j.selN("//*[text()='总字数']//text()[1]");
Assert.assertEquals(2, l.size());
// xpath索引值从1开始
List<JXNode> l2 = j.selN("//*[text()='总字数']//text()[0]");
Assert.assertEquals(0,l2.size());
List<JXNode> l3 = j.selN("//*[text()='总字数']//text()[2]");
Assert.assertEquals(0,l3.size());

}

}

0 comments on commit 7bb89fc

Please sign in to comment.