This repo aims to make Taiwan laws easy to process by computer geeks. The output includes:
- Law article in JSON
- Law change history in JSON
- Script to create Git repo of laws
- Progress of law motion in JSON
For single law
% npm run prepublish && ./node_modules/.bin/lsc law2json.ls --outdir output/law/json data/law/憲法/中華民國憲法
..or all
% npm run prepublish && find data/law -type d -depth 2 -exec ./node_modules/.bin/lsc law2json.ls --outdir output/law/json {} +
% (mkdir output/law && cd output/law && git init)
% for dir in `find output/law/json -type d -depth 2`; do
./json2git.py $dir/law_history.json output/law
done
The source pages are committed so that we can check for updates. But if you need to fetch the source yourself, here is the instruction
- http://lis.ly.gov.tw/lgcgi/lglaw -> 分類瀏覽 -> 任意一筆
- Copy the link in address bar to $PARTAL in prepare_categories.sh
% ./prepare_categories.sh # probably need to update the link manually
% ./fetcher.sh data/file-link.txt
Fetch a single category
% npm run prepublish && ./node_modules/.bin/lsc prepare_law.ls --cat 憲法 --dir data/law
% ./fetcher.sh data/law/憲法/file-link.tsv
..or fetch every categories
% npm run prepublish
% for cat in data/law/*; do
./node_modules/.bin/lsc prepare_law.ls --cat `basename $cat` --dir data/law
./fetcher.sh $cat/file-link.tsv
done
Currently it's done manually.
- Open http://lis.ly.gov.tw/lgcgi/ttsweb?@0:0:1:lgmempropg08@@0
- 選第一個會期、到最後一個, then search
- click 詳目顯示
- open javascript console
- localStorage['page'] = 1
- document.querySelector('select[name="_TTS.DISPLAYPAGE"]').options[0].value = 200; document.querySelector('input[name="_TTS.PGTOP"]').value = 200*(localStorage['page']-1)+1; localStorage['page']++; document.querySelector('input[name="_IMG_顯示結果"]').click();
- document.querySelector('input[name="_IMG_本頁全部"]').click();
- repeat 2 until you got every pages.
- organize (e.g. rename) local files.
% ./node_modules/.bin/lsc parse_progress.ls --ad 8 > progress.json
# one record per line for mongodbimport
% ./node_modules/.bin/lsc parse_progress.ls --ad 8 --newline > progress.json