News for hackers. Stuff that matters.
Re:HN “Why Not Simply” by 1vuio0pswjnm7 on Monday June 07, 2021 @01:17AM (#27419224)
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/

^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);
Re:HN “Why Not Simply” by 1vuio0pswjnm7 on Monday June 07, 2021 @03:47PM (#27426669)
small 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);**
Re:HN “Why Not Simply” by pjc50 on Monday June 07, 2021 @06:01AM (#27420784)
Why not just use a web browser?

(sorry)