從 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 值。