2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pythonを使ってconnpassイベントをキーワード検索

Last updated at Posted at 2021-02-13

Pythonを使ってconnpassイベントをキーワード検索

公式ドキュメント ... https://connpass.com/about/api/

リクエストURL

パラメーター
keyword_or ... キーワード (,)区切りで複数選択
ym ... 取得年月(YYYYMM)(,)区切りで複数選択
order ... 表示順(1: 更新日時順, 2: 開催日時順, 3: 新着順)
count ... 取得数

例:
https://connpass.com/api/v1/event/?keyword_or=php,laravel,wordpress&ym=202102,202103&order=1&count=100

Python側

キーワード、取得年月、取得数で検索できるようにした
結果は加工しやすいようにDataFrameに入れた

def get_search(keyword: str, ym: str, count: int = 100):

    df = pd.DataFrame(
        columns=[
            "id",
            "title",
            "catch",
            "description",
            "event_url",
            "hash_tag",
            "started_at",
            "ended_at",
            "limit",
            "address",
            "place",
            "owner_id",
            "owner_nickname",
            "owner_display_name",
            "accepted",
            "waiting",
            "updated_at",
        ],
    )

    url = (
        f"https://connpass.com/api/v1/event/?keyword_or={keyword}"
        f"&ym={ym}&count={count}"
    )
    response = requests.get(url)
    resources = response.json()

    for event in resources["events"]:

        df = df.append(
            {
                "id": event["event_id"],
                "title": event["title"],
                "catch": event["catch"],
                "description": event["description"],
                "event_url": event["event_url"],
                "hash_tag": event["hash_tag"],
                "started_at": event["started_at"],
                "ended_at": event["ended_at"],
                "limit": event["limit"],
                "address": event["address"],
                "place": event["place"],
                "owner_id": event["owner_id"],
                "owner_nickname": event["owner_nickname"],
                "owner_display_name": event["owner_display_name"],
                "accepted": event["accepted"],
                "waiting": event["waiting"],
                "updated_at": event["updated_at"],
            },
            ignore_index=True,
        )

    return df

今回はphp,laravel,wordpressを対象に202102,202103のイベントを取得

search = connpass.get_search("php,laravel,wordpress", "202102,202103")

結果

        id                            title  ... waiting                 updated_at
0   204563                 ヘッドレスWordPress入門  ...       0  2021-02-13T20:30:41+09:00
1   204610    (若手?)エンジニアもくもく会 vol.34 @Slack  ...       0  2021-02-13T19:59:55+09:00
2   204076           もくもく会in神戸 #2【三宮&ウェブ開催】  ...       0  2021-02-13T18:15:58+09:00
3   200508       TwilioQuest - 2021 新春チャレンジ  ...       0  2021-02-13T17:19:22+09:00
4   204362             【超入門】Webサイトをデプロイしよう!  ...       0  2021-02-13T16:54:57+09:00
..     ...                              ...  ...     ...                        ...
72  202607             名古屋駅前 もくもく会 2021.2.7  ...       0  2021-01-25T21:56:44+09:00
73  202576           サーバー構築ハンズオン@オンライン #129  ...       0  2021-01-25T15:14:45+09:00
74  201718    第73回【オンライン開催】PORTもくもく会【学生歓迎!】  ...       0  2021-01-16T14:19:06+09:00
75  201342                  錦糸町 朝活・もくもく会 #3  ...       0  2021-01-13T07:26:46+09:00
76  198286  [新宿御苑前]がやがやと勉強する会(テーマ自由、初心者歓迎!)  ...       0  2021-01-12T13:50:49+09:00

connpassイベントを取得できました
いいね!と思ったら LGTM お願いします :clap::clap::clap:

【PR】週末ハッカソンというイベントやってます! → https://weekend-hackathon.toyscreation.jp/about/

2
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?