Help us understand the problem. What is going on with this article?

Slackbotでwikipediaのランダムな記事を表示させる

More than 1 year has passed since last update.

なんとなくネットを眺めていたらPythonのwikipediaモジュールなるものを発見しました。どうやらWikipediaのページを取得できるらしい…

ということでこちらで作ったBotに組み込んで使ってみました。

wikipedia.py
# coding: utf-8

from slackbot.bot import respond_to
import wikipedia

@respond_to('wikipedia')
def get_random_wikipedia_page(message):
    # set_langにjaを指定することで日本語の記事のみ取得します
    wikipedia.set_lang("ja")
    message.reply("https://ja.wikipedia.org/wiki/" + wikipedia.random())

以下、取得したページの一例。絶対自分では調べないようなページが出てきて、ちょっと楽しい。
スクリーンショット_2018-10-27_3_35_31.png
スクリーンショット_2018-10-27_3_35_47.png
スクリーンショット_2018-10-27_3_36_12.png
スクリーンショット_2018-10-27_3_36_22.png
スクリーンショット_2018-10-27_3_39_00.png

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away