Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tf63/atcoder-offline-python
AtCoderの問題・解説ページのスクリーンショットをGoogle Drive上に収集するツール
https://github.com/tf63/atcoder-offline-python
Last synced: 24 days ago
JSON representation
AtCoderの問題・解説ページのスクリーンショットをGoogle Drive上に収集するツール
- Host: GitHub
- URL: https://github.com/tf63/atcoder-offline-python
- Owner: tf63
- License: other
- Created: 2023-03-15T14:32:38.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-25T05:08:59.000Z (almost 2 years ago)
- Last Synced: 2024-11-28T13:51:43.564Z (3 months ago)
- Language: Python
- Homepage:
- Size: 2.29 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AtCoder Offline
**概要**
- オフラインでAtCoderの問題・解説ページを見れる環境を作る
**何をするか**
- 指定したコンテストの問題・解説ページのスクリーンショットを撮影し,Googleドライブに保存する
- [AtCoder Problem](https://kenkoooo.com/atcoder/#/table/)の[Information API](https://kenkoooo.com/atcoder/resources/problem-models.json)から各問題のDifficultyを取得し,Difficultyごとに保存

- Notionのデータベースにノートを用意する

---## 実行方法
- 実行コマンド- abc280からabc284までのA, B, C問題がダウンロードされる
```
python -m atcoder_offline --prefix abc --begin 280 --end 284 --problem a b c
```
- `--clear_done`オプションをつけることで,NotionのデータベースでDoneとした問題をGoogleドライブから削除できる---
## 各種設定
## .env
- **必ず`.env.example.json`を`.env`にリネームする**
- .envファイルにはAPIトークンを保管するため,絶対にgit管理しない## docker
- docker-compose内の`selenium`コンテナのイメージを次のように変更する- intelチップの場合,`image:selenium/standalone-chromium`
- M1/M2チップ搭載のmacの場合,`image:seleniarm/standalone-chromium`---
## Goodleドライブ APIの有効化
- Google Drive APIを有効にし,PyDrive2からGoogleドライブを操作できるようにする- 参考 https://qiita.com/ftnext/items/60ced8bc432bec6101f0
## Goodleドライブの保存先
**フォルダ構成**
- フォルダ名は固定- 保存先のディレクトリをオフラインで使用可能にしておく

**フォルダIDの取得**
- `env.json`の`COLOR_TO_DIR`に,それぞれの色に対応するフォルダIDを設定する- フォルダIDは,フォルダを開いてURLを確認することで得られる
```
https://drive.google.com/drive/folders/<フォルダID>
```
---## Notion APIの有効化
- https://www.notion.so/my-integrations からインテグレーションを作成し,トークンを取得- ******************の部分をコピーし,`env.json`の`TOKEN_NOTION`に割り当てる

参考 (公式) https://developers.notion.com/docs/create-a-notion-integration
## Notion データベースの用意
**データベースの作成**
- プロパティに`contest`, `color`, `status`を持つデータベースを作成する
**インテグレーションの接続**
- コネクトの追加から,作成したインテグレーションを追加する
---
## 結果
**実行結果**
**statusの更新**
![]()
---
## 参考
macの場合,ベースイメージをseleniumではなくseleniarmを使う (docker-compose)https://qiita.com/xy2e45/items/2895fe98e79fe9da3d9c
Seleniumを使ってスクリーンショット
https://tech-lab.sios.jp/archives/28840
Googleドライブの操作
https://note.nkmk.me/python-pydrive-folder/
beautifulsoup
https://senablog.com/python-bs4-search/
https://qiita.com/d_m/items/f477c6665ec69dfaf594
https://pystyle.info/scraping-beautiful-soup-how-to-refer-elements/#outline__11