问题描述
我正在尝试从站点提取数据以构建数据库.
I am trying to extract data from a site to construct a database.
我想将数据从"h2#1"提取到"h2#2"之前的行,
并将其放入Element中,以便我可以更轻松地处理数据.
I want to extract the data from "h2#1" to the line before "h2#2",
and put it into Element, so that I can handle the data easier.
图片中显示的数据位于div中,其中id ="left"
The data shown in the picture is within a div where id="left"
我要提取数据的页面:
http://koryaku.fullbokko.drecom.jp/quests/sp /eiketsu_sinka_no_hihou/netureinokishi/#1
The page I am trying to extract data:
http://koryaku.fullbokko.drecom.jp/quests/sp/eiketsu_sinka_no_hihou/netureinokishi/#1
推荐答案
尝试使用此CSS选择器:
Try this CSS selector:
h2#1 ~ *:not(h2#2 ~ *):not(h2#2)
演示
http://try.jsoup.org/~T29QSXFbJqwJx2a_If4qUeD1cnU
h2#1 ~ * /* Select any node preceded by h2#1 ... */
:not(h2#2 ~ *) /* ... and not preceded by h2#2 ... */
:not(h2#2) /* ... and exclude h2#2 itself ! */
在Jsoup 1.8.3上进行了测试
这篇关于如何使用Jsoup提取节点A和节点B之间的任何节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!