学内サイトの休講情報をスクレイピングしてTwitterに投げる。
$ python3 -m venv env
$ . env/bin/activate
$ pip install -r requirements.txt
GoogleカレンダーAPIのcredentialを取得する。
https://console.developers.google.com/apis/credentials
プロジェクトの選択→クライアントIDを選択→JSONをダウンロード→ credential.json
として保存
$ python calAdd.py --noauth_local_webserver
ブラウザに表示された認証コードをターミナルに貼り付ける。
走らせる。
$ python main.py
Cronに登録する場合は以下のようにCronを登録する。
#!/bin/bash -xe
cd /home/foo/cancelChecker
. env/bin/activate
python main.py
$ crontab -e
*/5 * * * * /bin/bash /home/foo/run.sh
- bs4で学内サイトをスクレピング
- 取得したデータを解析して過去のデータと比較
- 新たなデータのみを取り出してTwitterに投稿
Googleカレンダの扱い: https://gist.github.com/tomoyk/a46b2e181ff76a82fddf45566d68a9f0