Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jan 29, 2024
1 parent 85545f5 commit b0f9d94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public class LoadHNTitle {

public static void main(String[] args) throws IOException {
try (Reader reader = new InputStreamReader(new URL("https://news.ycombinator.com/").openStream(), StandardCharsets.UTF_8)) {
// select td.title > a.storylink
NodeMatcher matcher = Selector.select().element("td").hasClass("title").withChild().element("a").hasClass("storylink").toMatcher();
// select td.title > span.titleline > a
NodeMatcher matcher = Selector.select().element("td").hasClass("title").withChild().element("span").hasClass("titleline").withChild().element("a").toMatcher();
JFiveParse.parse(reader).getAllNodesMatching(matcher).stream()
.map(Element.class::cast)
.forEach(a -> System.out.println(a.getTextContent() + " [" + a.getAttribute("href") + "]"));
Expand Down

0 comments on commit b0f9d94

Please sign in to comment.