News for hackers. Stuff that matters.
Re:Babashka is a fast-starting scripting environment for Clo... by nerpderp82 on Thursday December 08, 2022 @01:12PM (#33911090)
What libraries do you use? I do most of my scraping in Python using beautifulsoup.
Re:Babashka is a fast-starting scripting environment for Clo... by Borkdude on Thursday December 08, 2022 @01:23PM (#33911227)
Babashka doesn't have a built-in HTML parsing library but it supports it through pods:

https://github.com/babashka/pod-registry

Pods can be written in any language and they can expose functions to babashka by implementing a protocol.

One pod exposing HTML parsing is:

https://github.com/retrogradeorbit/bootleg

Here is an example of how to use that:

https://github.com/babashka/pod-registry/blob/master/example...

Re:Babashka is a fast-starting scripting environment for Clo... by timdeve on Thursday December 08, 2022 @03:33PM (#33912954)
As other people have said Bootleg + Hickory.

Here is an, admitedly not very clean, example that grabs stream urls from hltv.org:

https://github.com/TimDeve/.dotfiles/blob/master/scripts/gen...

Also a basic RSS reader using the clojure XML lib:

https://github.com/TimDeve/.dotfiles/blob/master/scripts/gen...

Re:Babashka is a fast-starting scripting environment for Clo... by noblepayne on Thursday December 08, 2022 @02:29PM (#33912094)
As mentioned by the one and only Borkdude, bootleg is a nice option for this.

It includes the Hickory library: https://github.com/clj-commons/hickory

I'm a previous BeautifulSoup user and have found the combination of (1) having the scraped data presented in plain Clojure data structures, and (2) Hickory's built in selectors, to be a very nice experience.

Happy scraping!

Re:Babashka is a fast-starting scripting environment for Clo... by aeonik on Thursday December 08, 2022 @01:20PM (#33911186)
Not OP but I use Reaver with good results. It supports all of JSoup's selectors, and makes it very clean to extract data from HTML.

The documentation is a little lacking though, I had to look up other examples on GitHub to figure out how to use all the features.

https://github.com/mischov/reaver

Re:Babashka is a fast-starting scripting environment for Clo... by nathell on Thursday December 08, 2022 @02:48PM (#33912334)
I plan to port my scraping framework (Skyscraper, https://github.com/nathell/skyscraper) to babashka one day. I’m not sure how easy it will be, though, since it uses core.async (which I believe bb has limited support for) and SQLite via clojure.java.jdbc.
Re:Babashka is a fast-starting scripting environment for Clo... by kot-behemoth on Friday December 09, 2022 @01:47PM (#33925007)
Core.async is listed as “built-in” in the Babashka Toolbox (https://babashka.org/toolbox). Might be worth checking if the compatibility has improved.

And bb supports Honey SQL and SQL pods (https://github.com/babashka/babashka-sql-pods) - so you might be already compatible!

Re:Babashka is a fast-starting scripting environment for Clo... by nerpderp82 on Thursday December 08, 2022 @07:53PM (#33916005)
Thanks everyone, all great pointers. I'll do my next scrape in Babashka!