# README ## 該專案目前僅供個人使用,暫不公開 ## 簡述: 台北市政府分別提供符合條件之市民兩種復康巴士預約的網站服務並提供符合條件之市民相應的補助,對於偶爾有需要的民眾這兩個網站已足以使用,但對於有長期復康巴士使用需求的人(如洗腎患者),非常難以使用,幾乎需要每天都做一次下訂單的動作,該專案透過電腦排程的方式**自動化訂車**並**自動更新目前已下訂的訂單方便查閱**。 * 該專案提供**台北市**的**小型復康巴士自動訂車**與小型復康巴士、長照2.0訂車平台的**訂單自動查詢** * 目前該專案僅在 Ubuntu 22.04 LTS 使用過 ## 開發環境 * OS:Ubuntu 22.04 LTS * python 3.10.12 * selenium 4.23.0 * requests 2.25.1 ## 使用前設定(長照2.0訂車) 1. 若尚未安裝request,執行 pip install requests 3. 編輯檔案 用於登入:long_take_care_of/setting/account.json ## 使用前設定(小型復康巴士預約) 1. 若尚未安裝selenium套件,執行 pip install selenium 2. 編輯檔案 用於登入與生成訂單:rehabus/setting/base_order.json 用於生成週期性訂單:rehabus/setting/priod_order_setting.json 如果有非週期性訂單:rehabus/order/special_order.json ## 功能(預約車) * reserve_rehabus.py ## 功能(查詢訂單) * write_care_bus_ordered.py * write_rehabus_ordered.py ## 功能(訂單整合,整合復康巴士與長照車的已定訂單) * current_order/merge_current_ordered.py ## 查看已訂訂單(執行完查詢訂單與訂單整合後) * current_order/order.txt ## 設定定時發送已訂訂單到指定電子信箱 * 依照以下教學完成透過gmail帳號發送電子信箱的設定 https://hackmd.io/@Axddd/SkKEIWRjR * 編輯 script/send_ordered_to_myMail.sh 將 Line 10 的 example@gmail.com 替換成想發送到的電子信箱 ## 自動化訂車排程範例 使用 crontab -e 指令 並寫入 (使用時請將各路徑的 /home/yu-alex/Program-Self/pyProgram/autoReserveBus 部份替換為自己電腦對應的路徑,並設定成自己想要執行的時間) 25 08 * * * /usr/bin/python3 /home/yu-alex/Program-Self/pyProgram/autoReserveBus/create_order_for_rehabus.py >> /home/yu-alex/Program-Self/pyProgram/autoReserveBus/log/create_order_for_rehabus.log 2>&1 30 08 * * * /usr/bin/python3 /home/yu-alex/Program-Self/pyProgram/autoReserveBus/reserve_rehabus.py >> /home/yu-alex/Program-Self/pyProgram/autoReserveBus/log/reserve_rehabus.log 2>&1 00 09 * * * /usr/bin/python3 /home/yu-alex/Program-Self/pyProgram/autoReserveBus/write_rehabus_ordered.py >> /home/yu-alex/Program-Self/pyProgram/autoReserveBus/log/write_orderd.log 2>&1 05 09 * * * /usr/bin/python3 /home/yu-alex/Program-Self/pyProgram/autoReserveBus/write_care_bus_ordered.py >> /home/yu-alex/Program-Self/pyProgram/autoReserveBus/log/write_orderd.log 2>&1 10 09 * * * /usr/bin/python3 /home/yu-alex/Program-Self/pyProgram/autoReserveBus/current_ordered/merge_current_ordered.py >> /home/yu-alex/Program-Self/pyProgram/autoReserveBus/log/write_orderd.log 2>&1 30 09 * * 2,5,7 /home/yu-alex/Program-Self/pyProgram/autoReserveBus/script/send_ordered_to_myMail.sh \# 第一條是創建想要訂車的訂單(復康巴士) \# 第二條是訂復康巴士的車 \# 第三條是查詢訂單並將結果寫入某檔案(復康巴士) \# 第四條是查詢訂單並將結果寫入某檔案(長照車) \# 第五條是將查詢到的復康巴士跟長照車的訂單做整併後寫入某檔案 \# 第六條是固定時間執行腳本,該腳本會寄送已訂定單到設定的電子郵件 ## 程式核心 * rehabus/rehabus.py : 提供對小型復康巴士訂車網站的操作的class >網站:[ https://0809080650.gov.taipei/index.jsp ] * long_take_care_of/care_bus.py : 提供對長照2.0訂車平台的操作的class >網站:[ https://tpe.mass.org.tw/client/Login?fbclid=IwZXh0bgNhZW0CMTAAAR3TINxr2L_XS1MhdU0eZPdF86ZmQQjlXQHsHAV-E9bspoKUHus6BX8fFiE_aem_-bSwSNQ3HC67z4tRUSdN9g ] * rehabus/manage_order_tool_for_rehabus.py : 提供復康巴士訂單管理的相關function