3 ms·
simpler HN search. why not. text-only, no Javascript required, no SNI, unnecessary HTTP headers, DNS, etc. json_reformat is from https://github.com/lloyd/yajl
by 1vuio0pswjnm7 5y ago
simpler HN search. why not.
text-only, no Javascript required, no SNI, unnecessary HTTP headers, DNS, etc.
json_reformat is from https://github.com/lloyd/yajl/ https://github.com/lloyd/yajl/
^M is Ctrl-v+Ctrl-m
example usage:
1.sh query > 1.json
json_reformat < 1.json|sed 's/ *//;s/\\n/ /g'|less
stunnel -fd 0 <<eof1
debug=debug
pid=$HOME/1.pid
foreground=no
[ $$ ]
accept=127.0.0.7:80
client=yes
connect=54.217.76.129:443
options=NO_TICKET
options=NO_RENEGOTIATION
renegotiation=no
sni=
sslVersion=TLSv1.3
sslVersionMin=TLSv1.2
eof1
nc -vvn 127.7 80 <<eof2
POST /1/indexes/Item_production_ordered/query?x-algolia-agent=Algolia%20for%20JavaScript%20(4.0.2)%3B%20Browser%20(lite)&x-algolia-api-key=8ece23f8eb07cd25d40262a1764599b1&x-algolia-application-id=UJ5WYC0L7X HTTP/1.1^M
Host: uj5wyc0l7x-dsn.algolia.net^M
Connection: close^M
Content-Type: x-www-form-urlencoded^M
Content-Length: $((${#@}+393))^M
^M
{"query":"$@","analyticsTags":["web"],"page":0,"hitsPerPage":30,"minWordSizefor1Typo":4,"minWordSizefor2Typos":8,"advancedSyntax":true,"ignorePlurals":false,"clickAnalytics":true,"minProximity":8,"numericFilters":[],"tagFilters":["story",[]],"typoTolerance":true,"queryType":"prefixNone","restrictSearchableAttributes":["title","comment_text","url","story_text","author"],"getRankingInfo":true}
eof2
cd;kill $(cat 1.pid);
- pjc50 5y agoWhy not just use a web browser? (sorry)
- 1vuio0pswjnm7 5y agosmall correction example usage: sed -n '/{\"hits\":/p' 1.json|json_reformat|sed 's/ //;s/\\n/ /g'|less also instead of entering ^M, we can use something like djb's "addcr" from ucspi-tcp, a simple program that adds a carriage return ("\r") to each line here is a simple shell version of addcr that also removes indention x=$(echo x|tr x '\r'); exec sed "s/ *//;s/$/$x/"; example usage: stunnel -fd 0 <<eof1 pid=$HOME/1.pid foreground=no [ $$ ] accept=127.0.0.21:80 client=yes connect=graphql.example.com:443 sslVersion=TLSv1.3 eof1 addcr <<eof2|nc -vvn 127.21 80 POST /v1/api HTTP/1.1 Host: graphql.example.com Connection: close Content-Type: x-www-form-urlencoded Content-Length: $((${#@}+141)) {"query":"$@"} eof2 cd;kill $(cat 1.pid);**