My morning brief script found only 2 stories on my topics yesterday. The day before, it found 4. Was the API's answer different, or is my filter wrong?
How do you find out?
You add print(resp.read()) to the script, run it, and get one 200 KB line of JSON in your terminal. You also want the headers, so you add more prints. If the script used curl, you'd add -v and read TLS handshake lines. Either way, you're changing the script to see what it does, and later you have to remember to take it all out.
With cmdbook, you can watch the requests from the outside.
Here's how
1. Turn on capture for the command. In the command's settings, check Capture HTTP traffic. The script stays exactly as it is.
2. Run it. cmdbook starts a small proxy on your machine and points the command at it, with the usual HTTP_PROXY / HTTPS_PROXY variables. For HTTPS, it also hands the command its certificate through the variables curl, Python and Node read, so there's nothing to install or trust for them.
3. Open the HTTP Capture tab. Every request the script made is listed, with its method, URL and status. Mine was one call:
GET https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=100 200 4. Click it. Request headers, request body, response headers, response body, each on its own. The answer to my question was right there: the front page came back complete, and only 2 of its stories matched my topics. The filter was fine; it was a quiet day for my topics.
It works with anything that respects the standard proxy variables: curl, wget, Python (urllib, requests, httpx), and most command-line tools. It doesn't see what ignores them, such as Node's built-in fetch by default. Browsers also need the cmdbook certificate trusted once (there's a Trust CA button).
HTTP Capture is part of cmdbook Pro.
Try cmdbook here: printf.app/cmdbook
