Skip to content

Instantly share code, notes, and snippets.

@gjp0609
Created January 7, 2019 08:05
Show Gist options
  • Save gjp0609/3fc8bbec4bca62ab05dd4ab92678a307 to your computer and use it in GitHub Desktop.
Save gjp0609/3fc8bbec4bca62ab05dd4ab92678a307 to your computer and use it in GitHub Desktop.
Jsoup parse html in sinngle line
// https://www.metacritic.com/browse/games/release-date/available/ps4/metascore
Jsoup.parse(new BufferedReader(new FileReader(new File("C:/Files/ps4.html")))
.lines()
.reduce(Jsoup.parse(new BufferedReader(new FileReader(new File("C:/Files/ByUser.html")))
.lines()
.reduce("", (acc, item) -> acc + item)).toString(), (acc, item) -> acc + item))
.select(".product_wrap")
.stream()
.sorted(Comparator.comparing(e -> ((Element) e).select(".textscore").text()).reversed())
.map(item -> "\033[106m "
.concat(item.select(".textscore").text())
.concat(" \033[102m ")
.concat(String.format("%3s", item.select(".metascore_w").text()))
.concat(" \033[91m ")
.concat(item.select("a").text()))
.distinct()
.forEach(System.out::println);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment