LoginSignup
2
4

More than 5 years have passed since last update.

社内の「connpassの新着イベントを東京限定にしてほしい」に応えてみた

Posted at

ニジボックスの社内で使っているSlackには、tech-eventというチャンネルがあります。
割と何となくレベルで、目についたりしたイベントを適当に紹介してくスタイルでした。 1

ある日。

https://connpass.com/explore/ja.atom これをここに流すのってどうですか?」

というがが出たので登録してみました。その結果...

  • Sota講習会 【Vstone Magicを始めよう】 Part 3(有料)
    • 東京都千代田区外神田1-9-9 内田ビル4F
  • 第1回 UDONPy もくもく会
    • 香川県高松市
  • 福島ゲームジャム2017【熊本会場】
    • 熊本県熊本市
  • 名古屋『FP in Scala』読書会 #28 - 13.4.3 純粋なインタープリタ
    • 名古屋市
  • #5 はじめてのIT勉強会 in 仙台
    • 宮城県仙台市

:tired_face: 遠い!!:tired_face:

connpassの新着イベントのフィードなので、そりゃもちろん登録されている全部が載ってきますよね。

社内の感想

ちょっと頻度高い気が..

:tired_face:

東京には限定してほしい

:tired_face:

left #tech-event

:tired_face:

スクリーンショット 2017-07-28 18.03.54.png

作った

server.py
import xml.etree.ElementTree as ET
import re
from urllib.request import urlopen
from bottle import route, run, HTTPResponse


@route('/')
def index():
    place_re = re.compile(r'<br />開催場所: (?P<place>.+?)<br />')
    resp = urlopen('https://connpass.com/explore/ja.atom')
    tree = ET.parse(resp)
    root = tree.getroot()
    for entry in root.findall('{http://www.w3.org/2005/Atom}entry'):
        summary = entry.find('{http://www.w3.org/2005/Atom}summary')
        place = place_re.search(summary.text).group('place')
        if '東京' in place:
            summary.text = "場所: {}".format(place)
            continue
        if 'Tokyo' in place:
            summary.text = "場所: {}".format(place)
            continue
        root.remove(entry)
    resp = HTTPResponse(status=200, body=ET.tostring(root))
    resp.set_header('Content-Type', 'application/atom+xml; charset=utf-8')
    return resp


run(host='0.0.0.0', port=8000)
$ python3 ./server.py
  1. 場所情報を抽出して
  2. 東京ぽいエントリー以外を全部捨てて
  3. SlackはURLプレビューあるから、Summaryを場所だけにして 2
  4. 作り直したDOMをそのままXMLにし直す

というのをリクエストするたびにやるだけのプログラムです。

必要な情報量にまで削ぎ落とせたので、だいぶチャンネルはある程度にスリムになったので良しとしましょう。


  1. 極稀に、感想スレッドもあったり 

  2. 最初のバージョンはsummary残してたのだけれど「URLだけでいいんじゃね?」という意見を元に編集することに 

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4