Hacker News new | ask | show | jobs
by aplorbust 3030 days ago
In case you receive the following message

"Sorry internet hipster, this little side project requires JavaScript."

here is a quick example of how to get the pages the "traditional way"[FN1]:

     #/bin/sh
     test $# -eq 2||exec echo usage: $0 source target;

     exec curl -H"Content-type: application/json" \
     -d '{"source":"'$1'","target":"'$2'"}' \
     https://api.sixdegreesofwikipedia.com/paths \
     |exec sed '
     s/\",/\"\
     /g;s/,\"/\
     \"/g;s/:{/:\
     {/g;s/}/&\
     /g;s/\"pages\":/&\
     /'
It appears the author is using the Wikipedia API. I did not add any HTML tags, etc. to the output, although this is very easy to do.

FN1. The original "web browsers" needed no GUI, no Javascript.

2 comments

Now it makes more sense.

I'd prefer to have a brief technical explanation why Javascript is needed instead of this condescending labeling.

Edit: NoScript is not a luxury for technically minded geeks anymore, it's a necessary protection against tracking, CPU-consuming advertisement and attacks like Spectre/Meltdown and who knows what else Intel has for us.

Example:

    sdow true false
Output:

     {"isSourceRedirected":false
     "isTargetRedirected":false
     "pages":
     
     {"161711":
     {"description":"Value indicating the relation of a proposition to truth"
     "title":"Truth value"
     "url":"https://en.wikipedia.org/wiki/Truth_value"}
     
     "228748":
     {"description":"Wikimedia disambiguation page"
     "title":"True"
     "url":"https://en.wikipedia.org/wiki/True"}
     
     "40805040":
     {"description":"Wikimedia disambiguation page"
     "title":"False"
     "url":"https://en.wikipedia.org/wiki/False"}
     }
     
     "paths":[[228748,161711,40805040]]
     "sourcePageTitle":"True"
     "targetPageTitle":"False"}
Edit sed commands to make first line indented:

     |exec sed '
     s/{/\
     &/;
     s/\",/\"\
     /g;s/,\"/\
     \"/g;s/:{/:\
     {/g;s/}/&\
     /g;s/\"pages\":/&\
     /'