show urls in !wikipedia output
This commit is contained in:
parent
63d9ab19d5
commit
76ccbbbc46
1 changed files with 9 additions and 6 deletions
|
@ -14,17 +14,20 @@ class Module(ModuleManager.BaseModule):
|
||||||
:usage: <term>
|
:usage: <term>
|
||||||
"""
|
"""
|
||||||
page = utils.http.request(URL_WIKIPEDIA, get_params={
|
page = utils.http.request(URL_WIKIPEDIA, get_params={
|
||||||
"action": "query", "prop": "extracts",
|
"action": "query", "prop": "extracts|info", "inprop": "url",
|
||||||
"titles": event["args"], "exintro": "",
|
"titles": event["args"], "exintro": "", "explaintext": "",
|
||||||
"explaintext": "", "exchars": "500",
|
"exchars": "500", "redirects": "", "format": "json"}).json()
|
||||||
"redirects": "", "format": "json"}).json()
|
|
||||||
if page:
|
if page:
|
||||||
pages = page["query"]["pages"]
|
pages = page["query"]["pages"]
|
||||||
article = list(pages.items())[0][1]
|
article = list(pages.items())[0][1]
|
||||||
if not "missing" in article:
|
if not "missing" in article:
|
||||||
title, info = article["title"], article["extract"]
|
title, info = article["title"], article["extract"]
|
||||||
info = info.replace("\n\n", " ").split("\n")[0]
|
title = article["title"]
|
||||||
event["stdout"].write("%s: %s" % (title, info))
|
info = utils.parse.line_normalise(article["extract"])
|
||||||
|
url = article["fullurl"]
|
||||||
|
|
||||||
|
event["stdout"].write("%s: %s - %s" % (title, info, url))
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("No results found")
|
event["stderr"].write("No results found")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue