Skip to content

Commit

Permalink
Merge pull request #34 from g0v/issue-33
Browse files Browse the repository at this point in the history
先這樣好了,至少更新 README  `--ignore-pipfile` 看起來[有點神秘](pypa/pipenv#3150) ,感謝幫忙測試~
  • Loading branch information
ddio committed Aug 16, 2019
2 parents 1681b19 + 3bb4c43 commit 6498feb
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pyOpenSSL = "==17.5.0"
Scrapy = "==1.5.0"
Twisted = "==17.9.0"
"zope.interface" = "==4.4.3"
psycopg2-binary = "==2.7.4"
psycopg2-binary = "==2.7.5"

[requires]
python_version = "3"
65 changes: 34 additions & 31 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 48 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,63 @@
長期收集各租屋網站、品牌公寓的可公開資訊,清洗後整理成格式統一的資料,供後續有需要的人使用。

- 專案資訊請見 [hackpad](https://g0v.hackpad.tw/Ih7Jp4pUD5y)
- 爬蟲套件請見 [PyPI](https://pypi.org/project/scrapy-tw-rental-house/)

## 程式使用方式與注意事項

# 程式使用方式與注意事項
本專案總共分為兩部份:

本程式還在初期開發階段,任何框架、資料庫定義、API 皆有可能更動。
1. 爬蟲本人,只需要 Scrapy 即可使用,不綁資料庫。
- [原始碼](https://github.com/g0v/tw-rental-house-data/tree/master/scrapy-package)
- [套件網頁](https://pypi.org/project/scrapy-tw-rental-house/)
2. 完整的開放資料流程,包含爬蟲、資料儲存、網頁。
- [原始碼](https://github.com/g0v/tw-rental-house-data)
- [網站](https://rentalhouse.g0v.ddio.io)

本專案還在初期開發階段,任何框架、資料庫定義、API 皆有可能更動。

關於開發的詳細資訊,請參見[專案 wiki](https://github.com/g0v/tw-rental-house-data/wiki/)

## 資料庫與網頁後端
### 環境需求
1. Python3 + pip
2. 需要安裝 [PostgreSQL](https://www.postgresql.org) ,否則 `wheel` 在 build `psycopg2-binary` 時會失敗。
3. 支援 GeoDjango 的資料庫,目前[主要的關聯式資料庫都有支援](https://docs.djangoproject.com/en/2.1/ref/contrib/gis/db-api/)。關於如何準備 GeoDjango 所需的系統環境,請參見[官方文件](https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/#installation)
### 爬蟲本人

關於環境需求與使用方式,請見[套件網頁](https://pypi.org/project/scrapy-tw-rental-house/)

### 資料庫與網頁後端

#### 環境需求

### Peewee -> Django 遷移步驟
1. 理論上可以直接用 Django 內建工具,因為 0001_migration 的內容與 Peewee 完全相同
2. 唯一的例外是 PostgreSQL ,請在遷移完畢後,執行 `python manage.py migratepeewee`
使用方式請參見 `--help`
1. Python3.5+
2. pip
3. pipenv (選用)
4. [PostgreSQL](https://www.postgresql.org) 9.5+
- 使用 PostgresSQL 以外的資料庫時,爬蟲可以順利執行,但使用內建的匯出指令時無法用 `-u --unique` 去除重複物件
5. GeoDjango ,目前[主要的關聯式資料庫都有支援](https://docs.djangoproject.com/en/2.1/ref/contrib/gis/db-api/)
- 關於如何準備 GeoDjango 所需的系統環境,請參見[官方文件](https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/#installation)

#### 資料庫設定

### 使用方式
```sh
# 安裝相關套件
# 使用 virtualenv 安裝相關套件
virtualenv -p python3 .
pip install -r requirements.txt
. ./bin/activate

# 也可使用 pipenv 安裝相關套件
pipenv install

cd backend
# 設定資料庫(預設使用 sqlite
# 設定資料庫(預設使用 sqlite)
## 詳細資訊請見 [Django 官網](https://docs.djangoproject.com/en/2.0/topics/settings/)
## 如果想用 PostgreSQL 9.3+ ,推薦打開 USE_NATIVE_JSONFIELD ,可以使用內建的 jsonb
vim backend/settings_local.py

# 設定資料庫
## 使用 --fake-init 可以讓 Django 跳過已存在的 migration script
## (如果你之前有乖乖把 DB 建好的話)
python manage.py migrate --fake-init
python manage.py migrate
python manage.py loaddata vendors
```

## 爬蟲

### 環境需求
1. Python3 + pip

### 使用方式
#### 爬蟲使用方式

確定資料庫準備完成後,執行以下步驟:

Expand All @@ -61,7 +74,13 @@ vim crawler/settings.py
./go.sh
```

### 注意事項
#### 資料匯出

```bash
python backend/manage.py export --help
```

#### 注意事項

1. 請友善對待租屋網站,依其個別網站使用規則容許的方式與頻率來查詢資料,建議可使用 Scrapy 內附的
[DOWNLOAD_DELAY](https://doc.scrapy.org/en/latest/topics/settings.html#std:setting-DOWNLOAD_DELAY)
Expand All @@ -71,12 +90,14 @@ vim crawler/settings.py
需符合現行法令的要求且自負其責,包括但不限於個人隱私、資料保護、資訊安全,以及公平競爭等相關規定。
4. 其他事項請參見[授權頁面](LICENSE)

## 網頁前端
### 網頁前端

#### 環境需求

### 環境需求
1. node 8+

### 使用方式
#### 使用方式

```sh
# 安裝套件
cd web/ui
Expand All @@ -89,9 +110,7 @@ npm run dev

詳細操作方式,請參見 [nuxt](https://nuxtjs.org/)


# 非宅界專案貢獻者
## 非宅界專案貢獻者

- [Lucien C.H. Lin (林誠夏)](lucien.cc)
- [勞工陣線](http://labor.ngo.tw/) 洪敬舒

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lazy-object-proxy==1.3.1
lxml==4.2.0
mccabe==0.6.1
parsel==1.4.0
psycopg2-binary==2.7.4
psycopg2-binary==2.7.5
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycparser==2.18
Expand Down

0 comments on commit 6498feb

Please sign in to comment.