{"by":"yoavm","descendants":7,"id":41695549,"kids":[41718732,41724223,41695582,41695552,41696229,41723911],"score":49,"text":"I often find myself in situations where I need to extract some data from a website, either as one time thing or periodically (and then watch for changes). Maybe I&#x27;m tracking stocks, or a delivery, or I want to know when tickets become available to the local sauna; maybe a friend called and asked &quot;can you get me all data from that website into a spreadsheet?&quot; (this happens surprisingly often)<p>I used to write one-off scripts for that, often with Python or JavaScript, but I noticed I spend about one minute getting the right CSS selectors, and then another 10 minutes setting the rest of the script up. I decided to write Pipet so that I&#x27;ll never need to write any of the boilerplate code again. By now I probably spent more time writing Pipet than all scrapers I have ever written, but hey, it&#x27;s been fun…<p>Pipet has two modes: curl and playwright. With curl, you can either type &quot;curl <a href=\"http:&#x2F;&#x2F;news.ycombinator.com\">http:&#x2F;&#x2F;news.ycombinator.com</a>&quot; or just copy-paste the request you want to duplicate from the browser. Pipet runs curl just like your shell does, so all headers and preferences work just the same. I found that this was super useful when trying to emulate a real browser or accessing something behind a login. With playwright mode, you just use JavaScript. If it worked in the devtools console, it should work with Pipet too.<p>Some other features I think are useful is that you can output the results as text, JSON, or write a template file for the results to be rendered into. You can also run Pipet with an interval, and run a command when the data changes. Lastly, Pipet fully integrates UNIX pipes, so you can do stuff like `div#main h1 | wc -c` and it will take the h1 from a div with id “main”, and pipe its HTML to `wc -c`. It makes it extremely easily to just use tools you already know to process the data before Pipet outputs it. It also works when processing JSON - you can call jq or whatever you like to use to help with the processing.<p>I’ve noticed I have written so many little scrapers since I have Pipet around because it became such an easy task, so hopefully others will find it useful too!","time":1727692050,"title":"Show HN: Pipet – CLI tool for scraping and extracting data online, with pipes","type":"story","url":"https://github.com/bjesus/pipet"}