Skip to content

Instantly share code, notes, and snippets.

@miawgogo
Last active May 23, 2017 18:31
Show Gist options
  • Save miawgogo/321b829da829cd7a2681e3004d999ec6 to your computer and use it in GitHub Desktop.
Save miawgogo/321b829da829cd7a2681e3004d999ec6 to your computer and use it in GitHub Desktop.
def wiki(info,usrs):
link="https://en.wikipedia.org/w/api.php"
payload = {'action': 'query', 'list': 'search', 'format': 'json', 'srsea$
page = requests.get(link, headers=headers, timeout=5, params=payload)
page.encoding = 'UTF-8'
response = json.loads(page.text)
result = response['query']['search'][0]
url = "https://en.wikipedia.org/wiki/" + result['title'].replace(" ", "_$
msg = "{}: {}... {}".format(result['title'], cleanhtml(result['snippet'].split(".")[0]), url)
say(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment