Live data from Hacker News

Show HN: Wiki – Command-line tool to fetch summaries from Wikipedia

github.com

1–10 of 10 posts

Re: Show HN: Wiki – Command-line tool to fetch summaries from Wikipedia

#3
That's a lot of code.

    curl -s "https://en.wikipedia.org/w/api.php?action=parse&contentmodel=wikitext&format=json&redirects&explaintext&prop=text&section=0&page=golang" | jq .parse.text.\"*\" > temp.html; links temp.html
(Scroll that). Not quite the same, but...

Re: Show HN: Wiki – Command-line tool to fetch summaries from Wikipedia

#6
post #3

That's a lot of code. curl -s "https://en.wikipedia.org/w/api.php?action=parse&contentmodel=wikitext&format=json&redirects&explaintext&prop=text&section=0&page=golang" | jq .parse.text.\"*\" > temp.html; links temp.html (Scroll that). Not quite the same, but...

jq? links?

my osx install does not seem to have these things.

Re: Show HN: Wiki – Command-line tool to fetch summaries from Wikipedia

#7
post #3

That's a lot of code. curl -s "https://en.wikipedia.org/w/api.php?action=parse&contentmodel=wikitext&format=json&redirects&explaintext&prop=text&section=0&page=golang" | jq .parse.text.\"*\" > temp.html; links temp.html (Scroll that). Not quite the same, but...

jq? links? my osx install does not seem to have these things.

You can download/install jq [0]. as for links, it is just a simple text browser. It could be substituted by elinks or lynx (although they are not present on a default Mac OS X installation either afaik), or you can just use the handler to open it in the browser of your choice.

[edit: typo]

[0] https://stedolan.github.io/jq/download/

Re: Show HN: Wiki – Command-line tool to fetch summaries from Wikipedia

#8
post #3

That's a lot of code. curl -s "https://en.wikipedia.org/w/api.php?action=parse&contentmodel=wikitext&format=json&redirects&explaintext&prop=text&section=0&page=golang" | jq .parse.text.\"*\" > temp.html; links temp.html (Scroll that). Not quite the same, but...

jq? links? my osx install does not seem to have these things.

and what about go?

Re: Show HN: Wiki – Command-line tool to fetch summaries from Wikipedia

#9
post #3

That's a lot of code. curl -s "https://en.wikipedia.org/w/api.php?action=parse&contentmodel=wikitext&format=json&redirects&explaintext&prop=text&section=0&page=golang" | jq .parse.text.\"*\" > temp.html; links temp.html (Scroll that). Not quite the same, but...

Yes, it's about 250 lines, and if you have links installed you could do something like this instead:

  bashwiki() {
   links -dump "https://en.wikipedia.org/wiki/$@" | head -n 60
  }
And call it with `$ bashwiki golang` and you get the summary (and some of the other text). My guess is that someone a little more familiar with bash could strip the extra output and make it a bit nicer though.

As they say "to each his own" :)