Metadata-Version: 2.1
Name: taiwanlottery
Version: 0.0.1
Summary: Taiwan Lottery Crawler 台灣彩券爬蟲
Home-page: UNKNOWN
Author: Cliff Su
Author-email: stu01509@gmail.com
License: MIT
Project-URL: Source, https://github.com/stu01509/TaiwanLotteryCrawler
Keywords: python,video,stream,video stream,camera stream,sockets
Platform: unix
Platform: linux
Platform: osx
Platform: cygwin
Platform: win32
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: requests >=2
Requires-Dist: beautifulsoup4 >=4
Requires-Dist: terminaltables >=3
Requires-Dist: pytest >=7.0
Requires-Dist: pytest-cov >=4.0
Requires-Dist: flake8 >=6.0
Requires-Dist: tox >=4.6
Provides-Extra: testing
Requires-Dist: pytest >=7.0 ; extra == 'testing'
Requires-Dist: pytest-cov >=4.0 ; extra == 'testing'
Requires-Dist: flake8 >=6.0 ; extra == 'testing'
Requires-Dist: tox >=4.6 ; extra == 'testing'

# Taiwan Lottery Crawler

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![Test Status](https://github.com/stu01509/TaiwanLotteryCrawler/actions/workflows/ci.yaml/badge.svg)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)

這個專案是用來爬取 [台灣彩券](https://www.taiwanlottery.com.tw/) 官網上歷史的開獎紀錄，目前支援**威力彩**、**大樂透**、**今彩539**、**雙贏彩** 4 種彩券遊戲。

## Features

- 爬取 威力彩、大樂透、今彩539、雙贏彩 4 種彩券遊戲的開獎紀錄。
- 爬取結果可直接輸出產生成 `json` 格式檔案進行後續使用。
- 針對單一的彩券遊戲可以爬取幾個月前的開獎紀錄。

## Requirements

- [requests](https://pypi.org/project/requests/)
- [BeautifulSoup](https://pypi.org/project/beautifulsoup4/)
- [terminaltables](https://pypi.org/project/terminaltables/)

## Install

```shell
git clone https://github.com/stu01509/TaiwanLotteryCrawler.git
cd TaiwanLotteryCrawler
pip install -r requirements.txt
```

## Build

```shell
python setup.py sdist bdist_wheel
```

## Publish

```shell
pip install twine
twine check .\dist\*
twine upload .\dist\*
```

## Command

### 爬取當月份的開獎紀錄

```shell
python crawl.py
```

### 爬取當月份的開獎紀錄並輸出 JSON

```shell
python crawl.py -o
```

### 往回爬取指定彩券的幾個月前的開獎紀錄

爬取 5 個月前的開獎資料

```shell
python crawl.py 威力彩 -b 5
```

```shell
python crawl.py 大樂透 -b 5
```

```shell
python crawl.py 今彩539 -b 5
```

```shell
python crawl.py 雙贏彩 -b 5
```

### 往回爬取指定彩券的幾個月前的開獎紀錄並輸出 JSON

爬取 5 個月前的開獎資料並輸出 JSON

```shell
python crawl.py 威力彩 -b 5 -o
```

```shell
python crawl.py 大樂透 -b 5 -o
```

```shell
python crawl.py 今彩539 -b 5 -o
```

```shell
python crawl.py 雙贏彩 -b 5 -o
```

### 爬取指定彩券的年月的開獎紀錄

爬取 2020 年 4 月份的開獎紀錄

```shell
python crawl.py 威力彩 -t 2020-04
```

```shell
python crawl.py 大樂透 -t 2020-04
```

```shell
python crawl.py 今彩539 -t 2020-04
```

```shell
python crawl.py 雙贏彩 -t 2020-04
```

### 爬取指定彩券的年月的開獎紀錄並輸出 JSON

爬取 2020 年 4 月份的開獎紀錄並輸出 JSON

```shell
python crawl.py 威力彩 -t 2020-04 -o
```

```shell
python crawl.py 大樂透 -t 2020-04 -o
```

```shell
python crawl.py 今彩539 -t 2020-04 -o
```

```shell
python crawl.py 雙贏彩 -t 2020-04 -o
```

### 指令說明

```shell
python crawl.py -h
```

## Data Source

- [威力彩](https://www.taiwanlottery.com.tw/Lotto/SuperLotto638/history.aspx)
- [大樂透](https://www.taiwanlottery.com.tw/Lotto/Lotto649/history.aspx)
- [今彩539](https://www.taiwanlottery.com.tw/Lotto/Dailycash/history.aspx)
- [雙贏彩](https://www.taiwanlottery.com.tw/Lotto/Lotto1224/history.aspx)

## License

MIT License


