Skip to main content

来自 PCSO 网站的网络抓取彩票结果的类库

项目描述

PCSOLotto

PCSOLotto (Webscraper) 是一个 Python 类库,用于从PCSO 网站抓取彩票结果

安装

使用 pip 安装到本地计算机。

pip install PCSOLotto-Webscraper

或者,如果您想要最新版本,请在本地计算机上使用 git 克隆此存储库:

git clone https://github.com/lonewanderer27/PCSOLotto_Webscraper

然后你可以将./src/PCSLotto/PCSOLotto.py文件复制到你想要使用它的 python 项目中。

命令行界面

结果以表格形式显示。

简单的使用示例

# display results today
# only works after 10PM or when PCSO has posted the results on the website.
./PCSOLotto.py -t

# display results yesterday
./PCSOLotto.py -y

# display results 3 days prior up to today
./PCSOLotto.py -z

注意:使用 -t --results_today、-y --results_yesterday、-z --results_default_pcso 会覆盖 -s --start_date 和 -e --end_date

高级用法示例

# display EZ2 results yesterday
./PCSOLotto.py -y --games 'EZ2'

# display EZ2, Suertres & 6Digit results yesterday
./PCSOLotto.py -y --games 'EZ2' 'Suertres' '6Digit'

# display Suertres 11AM Draw result yesterday
./PCSOLotto.py -y --games 'Suertres Lotto 11AM'

# display 6/55 & 6/49 results yesterday
./PCSOLotto.py -y --games '6/55' '6/49'

默认情况下,累积奖金价格以₱符号为前缀,您可以通过添加--peso_sign false参数来禁用它

# display 6/55 & 6/49 results yesterday
# but with ₱ sign omitted
./PCSOLotto.py -y --games '6/55' '6/49' --peso_sign false

更高级的使用示例

# display results from Aug 1 2022 to Aug 10 2022
# Note: the only accepted date format is YYYY/MM/DD

./PCSOLotto.py --start_date '2022/08/01' --end_date '2022/08/10'

# display 6/58 results from Aug 1 2022 to Aug 10 2022
./PCSOLotto.py --start_date '2022/08/01' --end_date '2022/08/10' --games '6/58'

# display 6/58, 6/55 & 6/42 results
# from Aug 1 2022 to Aug 10 2022
./PCSOLotto.py --start_date '2022/08/01' --end_date '2022/08/10' --games '6/58' '6/55' '6/42'

# display results every Mon, Wed, Fri
# from Aug 1 2022 to Aug 10 2022
./PCSOLotto.py --start_date '2022/08/01' --end_date '2022/08/10' --days Mon Wed Fri

# display only EZ2 results every Mon, Wed, Fri
# from Aug 1 2022 to Aug 10 2022
./PCSOLotto.py --start_date '2022/08/01' --end_date '2022/08/10' --days Mon Wed Fri --games 'EZ2'

有关游戏别名的完整列表以及如何过滤 EZ2 和 Suertres 的特定时间抽签,请参阅游戏表。

CLI 选项参考

usage: PCSOLotto.py [-h] [-s START_DATE] [-e END_DATE] [-t] [-y] [-z] [-d [DAYS ...]] [-g [GAMES ...]] [-p PESO_SIGN] [-c CSV] [-j JSON]

CLI tool for web scraping lottery results from the PCSO website

options:
  -h, --help            show this help message and exit
  -s START_DATE, --start_date START_DATE
                        date to start searching. Format: YYYY/MM/DD (default: None)
  -e END_DATE, --end_date END_DATE
                        date to end searching. Format: YYYY/MM/DD (default: None)
  -t, --results_today   retrieve lotto results today (default: False)
  -y, --results_yesterday
                        retrieve lotto results yesterday (default: False)
  -z, --results_default_pcso
                        retrieve lotto results from 3 days prior up to today (default: False)
  -d [DAYS ...], --days [DAYS ...]
                        days to select (default: None)
  -g [GAMES ...], --games [GAMES ...]
                        lotto games to search (default: None)
  -p PESO_SIGN, --peso_sign PESO_SIGN
                        to prefix a peso sign in the jackpot, or not (default: True)
  -c CSV, --csv CSV     csv file to output the results to (default: None)
  -j JSON, --json JSON  json file to output the results to (default: None)

API / 库

所有方法都返回一个字典,由包含实际结果的键组织。

简单的使用示例

from PCSOLotto import PCSOLotto
from pprint import pprint # for pretty printing of returned dictionary 

# initiate an object from the class
lotto = PCSOLotto()


# return results today
# only works 10PM onwards as that is when PCSO updates their website
pprint(lotto.results_today(), indent=2)


# return results yesterday
pprint(lotto.results_yesterday(), indent=2)


# return results for the past 3 days
# default selection on the PCSO website
pprint(lotto.results_latest(), indent=2)

高级用法示例

方法results_today()results_yesterday()并且results_latest()都有一个可选games参数,您可以在其中自定义返回的彩票游戏。

要匹配特定游戏,我们必须使用彩票游戏的别名或全名。有关这些别名,请参阅游戏表。

from PCSOLotto import PCSOLotto
from pprint import pprint # for pretty printing of returned dictionary 

# initiate an object from the class
lotto = PCSOLotto()


# return EZ2 results yesterday
pprint(
    lotto.results_yesterday(
        games=['EZ2']),
    indent=2)


# return EZ2, Suertres & 6Digit results yesterday
pprint(
    lotto.results_yesterday(
        games=['EZ2', 'Suertres', '6Digit']),
    indent=2)


# return 6/55 & 6/49 results yesterday
pprint(
    lotto.results_yesterday(
        games=['6/55', '6/49']),
    indent=2)

默认情况下,我们使用的所有三种方法都以 ₱ 符号作为累积奖金价格的前缀,您可以通过传递peso_sign=False参数来禁用它。

# return 6/55 & 6/49 results yesterday
# but with ₱ sign omitted
pprint(
    lotto.results_yesterday(
        games=['6/55', '6/49'], 
        peso_sign=False),
    indent=2)

更高级的使用示例

简单和高级用法中描述的方法都使用下面调用的方法,该方法采用API 参考results()中描述的五个参数

如果要自定义结果日期,可以直接使用此方法。

from PCSOLotto import PCSOLotto
from pprint import pprint # for pretty printing of returned dictionary 

# initiate an object from the class
lotto = PCSOLotto()


# Search for results from Aug 1 2022 to Aug 10 2022
# Note: the only accepted date format is YYYY/MM/DD
pprint(
    lotto.results(
        start_date='2022/08/01', 
        end_date='2022/08/10'),
    indent=2
)


# Search for 6/58 results from Aug 1 2022 to Aug 10 2022
pprint(
    lotto.results(
        start_date='2022/08/01', 
        end_date='2022/08/10', 
        games=['6/58']),
    indent=2
)


# Search for 6/58, 6/55 & 6/42 results
# from Aug 1 2022 to Aug 10 2022
pprint(
    lotto.results(
        start_date='2022/08/01', 
        end_date='2022/08/10', 
        games=['6/58', '6/55', '6/42']),
    indent=2
)


# Search for results every Mon, Wed, Fri
# from Aug 1 2022 to Aug 10 2022
pprint(
    lotto.results(
        start_date='2022/08/01', 
        end_date='2022/08/10', 
        days=['Mon', 'Wed', 'Fri']),
    indent=2
)

API参考

范围 类型 格式 描述
start_date string 年年/月/日 必填。开始搜索的日期
end_date string 年年/月/日 必填。结束搜索的日期
days list(string) ['太阳','星期一'] ... 可选。选择天数
games list(string) ['EZ2','Suetres'] ... 可选。游戏选择
peso_sign bool True或者False 可选。在累积奖金中添加比索符号前缀,或不添加

游戏表

注意:单独使用“Suertres”将匹配在上午 11 点、下午 4 点和晚上 9 点发生的所有抽奖

因此,如果您只想要 4PM 抽奖,请改用“Suertres Lotto 4PM”。相同的概念适用于 EZ2。

别名 游戏全名
6/58 超级乐透 6/58
6/55 大乐透 6/55
6/49 超级乐透 6/49
6/45 超级乐透 6/45
6/42 乐透 6/42
6位 6位
4位数 4位数
苏埃特 苏埃特
Suertres Lotto 上午 11 点 Suertres Lotto 上午 11 点
Suertres Lotto 下午 4 点 Suertres Lotto 下午 4 点
Suertres Lotto 晚上 9 点 Suertres Lotto 晚上 9 点
EZ2 EZ2 / 2 位
EZ2 乐透 11AM EZ2 乐透 11AM
EZ2 乐透 4PM EZ2 乐透 4PM
EZ2 乐透晚上 9 点 EZ2 乐透晚上 9 点

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

PCSOLotto_Webscraper-0.0.20.tar.gz (14.0 kB 查看哈希

已上传 source

内置分布

PCSOLotto_Webscraper-0.0.20-py3-none-any.whl (12.3 kB 查看哈希

已上传 py3