school + crawler 的簡稱 = scrawler
scrawler 是各大學的課程資訊爬蟲 目前支援:
- 中興
每次更新課程後
會自動匯入django所指定的資料庫 如Mysql
以及建立所有cal所需要查詢的表
省去複雜的步驟,讓維護cal變得輕鬆
建立的表如下:
- Django中
timetable.models.Course - MongoDB中
CourseOfDept - MongoDB中
CourseOfTime
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- OS:Ubuntu / OSX would be nice
- environment:need python3
sudo apt-get update; sudo apt-get install; python3 python3-dev - 需要
mongoDB:
- lxml dependencies
sudo apt-get install libxml2-dev libxslt-dev - cryptography dependencies
sudo apt-get install libssl-dev libffi-dev
git clone https://github.com/stufinite/scrawler- 使用虛擬環境:
virtualenv venv- 啟動方法
1. for Linux:
. venv/bin/activate2. for Windows:venv\Scripts\activate pip install -r requirements.txt
- 請確保
mongodb是啟動的,啟動mongoDB的指令為
- ubuntu:
sudo systemctl start mongod.service - macOS:
不確定
scralwer/settings.py的96行,請更新cal專案在該環境的絕對路徑,否則會無法存取資料到cal的資料庫中。
scrapy crawl NCHU -a semester=學期(1061 or 1062 or ...):個人開發時使用nohup python run.py 學期(1061 or 1062 or ...) &:佈署到伺服器時使用
因為run.py是一個無限回圈,所以讓他在背景執行即可
效果:看到start sleep且上方沒有任何error就是正常以上省略多行 ... 'item_scraped_count': 6, 'log_count/DEBUG': 14, 'log_count/INFO': 7, 'response_received_count': 7, 'scheduler/dequeued': 6, 'scheduler/dequeued/memory': 6, 'scheduler/enqueued': 6, 'scheduler/enqueued/memory': 6, 'start_time': datetime.datetime(2017, 2, 6, 13, 48, 44, 579855)} 2017-02-06 21:48:53 [scrapy.core.engine] INFO: Spider closed (finished) ----------------------------------- start sleep -----------------------------------
目前還沒寫測試...
目前沒有coding style tests...
- Scrapy
- scrapy-djangoitem
- 張泰瑋 david