从 HearthPwn (http://hearthpwn.com) 抓取《炉石传说》套牌,然后构建结果的 SQLite 数据库。还可以从 HearthPwn/Innkeeper (http://innkeeper.com) 抓取卡牌收集数据,并与 omgvamp 的 Mashape Hearthstone API (http://hearthstoneapi.com) 集成,构建卡牌数据表,可用于制作更多卡牌数据高级查询。
需要 lxml、cssselect 和 requests 包。可以通过在 hearthstats 文件夹中打开命令提示符并运行以下命令来安装它们:
pip install -r requirements.txt
usage: hearth.py [-h] [--buildcards] [--builddecks] [--buildcollection]
[--perclass] [--count COUNT] [--filtering FILTERING]
[--sorting SORTING] [--patch PATCH] [--results]
Scrape Hearthstone decks from HearthPwn (http://hearthpwn.com), then build a
SQLite database of the results. Can also scrape card collection data from
HearthPwn/Innkeeper (http://innkeeper.com), and integrates with omgvamp's
Mashape Hearthstone API (http://hearthstoneapi.com) to build a table of card
data that can be used to make more advanced queries.
optional arguments:
-h, --help show this help message and exit
--buildcards build card database from Mashape
--builddecks build deck database from HearthPwn
--buildcollection build personal card collection from Hearthpwn
--perclass get the same number of decks for each class
--count COUNT number of decks to retrieve (per class, if --perclass
is set)
--filtering FILTERING
the HearthPwn filter used when finding decks, as seen
in the HearthPwn URL
--sorting SORTING the HearthPwn sorting used when finding decks, as seen
in the HearthPwn URL after "&sort="
--patch PATCH the HearthPwn patch ID used when finding decks, as
seen in the HearthPwn URL after "&filter-build="
--results for all cards, display (in a CSV-ish format) the:
cardname, hero (or neutral), total count of decks
using the card, percentage of decks using the card,
average count of the card in decks using it, and the
count of the card in your collection.
在填充卡数据库之前,您必须首先在 Mashape.com 上注册 API 密钥。获得 API 密钥后,如果 config.ini 尚不存在,请将 config.ini.example 重命名为 config.ini,然后在文本编辑器中打开 config.ini(运行该脚本一次也会创建一个空白的 config.ini 文件) :
[Configuration]
mashapekey = keygoeshere
authsession = authsessiongoeshere
将此处的 keygoes 替换为您的 Mashape API 密钥。
在填充卡牌收藏数据库之前,您必须首先使用 Innkeeper 同步您的卡牌收藏。然后,登录您的 HearthPwn 帐户。使用 Web 浏览器的开发控制台(或其他 cookie 查看工具)获取 Auth.Session cookie 的值。获得 Auth.Session 值后,如果 config.ini 尚不存在,请将 config.ini.example 重命名为 config.ini,然后在文本编辑器中打开 config.ini(运行该脚本一次也会创建一个空白的 config.ini文件):
[Configuration]
mashapekey = keygoeshere
authsession = authsessiongoeshere
将 authsessiongoeshere 替换为您的 Auth.Session 值。