Sep 172014
 

I just came across (via jdp) this awesome command line dealie called pup:

https://github.com/EricChiang/pup

Totally awesome! The HTML equivalent to jq, it allows you to parse HTML using CSS selectors from the command line.

For example, say I wanted to get the top 10 current headlines from Hacker News:

$ curl https://news.ycombinator.com | pup td.title a text{} | head -n 10
Artificial sweeteners induce glucose intolerance by altering the gut microbiota
Show HN: CleverDeck – I built the spaced repetition app I always wanted
I was asked to crack a program in a job interview
Stuff Goes Bad: Erlang in Anger
Suture – Supervisor Trees for Go
The Design and Implementation of the FreeBSD Operating System, 2nd ed.
Easel Is Shutting Down
Dremel Releases a Mass-Market 3D Printer
The Traveling Salesman with Simulated Annealing, R, and Shiny
The New Yahoo Developer Network

SO COOL!!!

How about another example: let’s grab all mentions of apple-related things on the first 5 pages of Hacker News to see how popular all of this insanity is these days:

$ for page in {1..5} ; do curl -s -S https://news.ycombinator.com/news?p=$page | pup td.title a text{} | awk '{print tolower($0)}' | egrep 'apple|ios|osx|swift|xcode|iphone' ; done ;
ios 8 reviewed
swype - ios 8 keyboard
stripe lands apple in quest for $720b in payments
ios8 adoption, hour by hour
ios 8 review
why apple didn't use sapphire for iphone screens
a history of misses for radioshack
predictive photo sharing with ios8
everything that went wrong while building the tumblr ios share extension
apple pay and nfc are obsolete: this is how payments could work in the future
the iphones 6
apple watch: initial thoughts and observations
build your own apple ibeacon with a raspberry pi
interactive iphone 6 experiment in webgl

So awesome!!! Thank you Eric Chiang!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)