Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Asoul committed Mar 3, 2015
1 parent 97bdf8e commit fc76739
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
17 changes: 13 additions & 4 deletions README.md
Expand Up @@ -18,9 +18,11 @@

比如說把清單很長要分成三份的話,就可以分三隻爬蟲平行跑:

`python crawl.py 0 3`
`python crawl.py 1 3`
`python crawl.py 2 3`
```
python crawl.py 0 3
python crawl.py 1 3
python crawl.py 2 3
```

### 資料完整性

Expand All @@ -40,6 +42,10 @@

`python genCrontabScript.py` 可以產生每三秒戳一次的 crontab。

### 其他

1. 如果在凌晨 12 點之後到開市前要抓,目前 default 設置是不給抓的,怕昨天已經清理過檔案,又把資料用髒了。

## 資料格式

每天的資料會存在 `data` 中,當天的日期資料夾內(ex. `20150303`),裡面把所有抓的資料按股票編號放 `XXXX.csv` 中,`XXXX` 就是股票編號。
Expand Down Expand Up @@ -86,7 +92,10 @@ ex. `13:30:00,43.25,616,6690,43.25_43.30_43.35_43.40_43.45_,216_285_90_274_201_,
http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=STOCK_NUMBER&json=1&delay=0
```

example: [API 點擊測試](http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=1101.tw&json=1&delay=0)
example:

[API 點擊測試1](http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_1101.tw&json=1&delay=0)
[API 點擊測試2](http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_1101.tw|tse_0050.tw&json=1&delay=0)

- STOCK_NUMBER 是該隻股票的種類和號碼,ex. `tse_1101.tw`,也可以用 `|` 一次 query 很多筆股票資料。ex. `tse_1101.tw|tse_1102.tw|tse_1103.tw`
- json=1 不知為何,但參考的程式碼中是如此設定的
Expand Down
5 changes: 1 addition & 4 deletions crawl.py
Expand Up @@ -11,10 +11,7 @@
import math

# 從 stocknumber.csv 中讀出要爬的股票清單
stock_id_list = []
f = open('stocknumber.csv', 'rb')
for row in csv.reader(f, delimiter=','):
stock_id_list.append(row[0])
stock_id_list = [line.strip() for line in open('stocknumber.csv', 'rb')]

# 拆成小的 subtasks 的號碼
if len(sys.argv) == 3:
Expand Down
16 changes: 2 additions & 14 deletions genTodayVolumeFigure.py
Expand Up @@ -25,9 +25,6 @@
print 'Q_Q'
continue

# 資料格式
# t, z, tv, v

# 開盤第一筆
if len(dist) == 0:
dist[float(row[1])] = int(row[3])
Expand All @@ -50,15 +47,8 @@
else:
dist[float(row[1])] = int(row[2])

# 沒有抓到中間交易,但價位相同,暫時直接補上差額股數
# elif float(row[1]) == last_z:
# dist[float(row[1])] += int(row[3]) - last_v

# 沒有抓到中間交易,而且價位變了
# 沒有抓到中間交易
else:
# diff_stock = int(row[3]) - last_v - int(row[2])
# dist[last_z] += diff_stock
print row
if float(row[1]) in dist:
dist[float(row[1])] += int(row[2])
else:
Expand All @@ -78,6 +68,4 @@
stock_count += i[1]
print '%.2f: %7d' % (i[0], i[1])
print '(%.5f%%)' % (stock_count/last_v*100)
print ""
# print stock_id, ' = %f' % (float(stock_count)/last_v)
break
print ""

0 comments on commit fc76739

Please sign in to comment.