There are instances where so-called "web APIs" returning JSON do not offer as much information as webpage HTML. Example: HN webpages indicate which items are [flagged] or labeled as [dupe] but the "HN API" JSON does not. Using a UNIX filter we can create our own "API" by transforming the HTML to SQLite and querying data from HN webpages as an SQLite database.
Example usage, assuming "the" is a keyword/string of interest
# get count of stories with keyword/string
echo select count\(\) from t1 where title like \'%the%\'|sqlite3 0.db
# get count of all stories with keyword/string in the title that are flagged
echo select count\(id\) from t1 where title like \'%the%\' and status like \'%[flagged]%\'|sqlite3 0.db
# get list of all stories with keyword/string in the title that are flagged
echo select id,title from t1 where title like \'%the%\' and status like \'%[flagged]%\'|sqlite3 0.db
# get status counts for stories with keyword/string in title
echo select status from t1 where title like \'%the%\' order by status|sqlite3 0.db|uniq -c
415 [dead]
17 [dupe]
12 [dupe] [dead]
23 [flagged]
131 [flagged] [dead]
2320 [ok]
# get status counts for stories with keyword/string in title for the last week
x=$((`date +%s`-604800))
echo select status from t1 where title like \'%the%\' and time \> $x order by status|sqlite3 0.db|uniq -c
5 comments