Skip to content

Instantly share code, notes, and snippets.

Created April 9, 2020 05:52
What would you like to do?
Wikipedia as DNS Server
import httpclient, json, xmltree, q
proc wikipediaDns*(name: string): string {.inline.} =
const w = ""
let hc = newHttpClient()
for x in hc.getContent(w & name).parseJson{"query", "pages"}.pairs:
for u in q(hc.getContent(x.val{"fullurl"}.getStr)).select"table.infobox tbody tr a[href*=http]":
return u.attr"href"
echo wikipediaDns("Nim-lang")
echo wikipediaDns("OpenStreetMap")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment