公共游戏统计数据的包装https://ogame.org
ogame-stats的Python项目详细描述
ogame统计
围绕https://ogame.org的公共游戏统计数据的包装器和逻辑
检索在线游戏ogame
公共数据的一些类和方法。
此包是NOT旨在与帐户交互-无论如何,这是被禁止的。在
可能用于查询数据集、可视化结果以及通常用于进行数据分析。在
要求
取决于:
- python>;=3.6(使用f-string)
- xmltodict是将XML数据转换为更基本的python类型的一种方便方法
- 请求执行http请求和
- pandas对数据执行查询
安装
在一个新目录中使用您的首选版本创建virtualenv
virtualenv -p python3.<6,7,8> venv
安装包装
^{pr2}$使用
基本用法
最基本的用法应该是这样的。在
#%%importogame_stats#%% supply the two inputs to uniquely identify a universeuniverse_id=162community='en'#%% instantiate and thereby load the datauniverse=ogame_stats.UniverseQuestions(universe_id,community)
你可以看看数据集。在
#%% get a list of all the planetsuniverse.universeidplayernamecoords011Arakis1:1:2...............[4378rowsx4columns]#%% find some playersuniverse.playersidnamestatusalliance01LegoraNaN..............[751rowsx4columns]
高级用法
现在,数据本身很好。但让我们问它一些问题。 这需要你的帮助,因为问正确的问题是关键。
例如,查找用户的行星。在
##%% get the coordinates and names of all the planets of a playeruniverse.get_planets_of_player('someSpecialName')[{'coords':'1:45:4','name':'MotherPlanet'},{'coords':'1:144:2','name':'ColonyC'},{'coords':'1:145:3','name':'ColonyB'},{'coords':'1:303:5','name':'ColonyA'},{'coords':'5:119:9','name':'ColonyE'},{'coords':'1:289:9','name':'ColonyD'},{'coords':'1:389:9','name':'ColonyF'}]
或询问状态(活动、不活动、禁止、假日等)。在
universe.get_player_status('someSpecialName')'I'
或者直接转储someSpecialName
的所有内容:
universe.get_player_data('someSpecialName')
获取特定联盟内玩家的完整列表
universe.get_players_of_alliance('someAlliance')idnamestatusalliance291103910reabuilderNaN50023429210393014Funv500234312104181nightowlNaN500234...
查看联盟成员拥有的行星分布。在
universe.get_planets_distribution_by_galaxy('someAlliance'){'1':7,'2':17,'3':29,'4':38,'5':9,'6':9,'7':9,'8':2,'9':6}
数据更新频率
不要向服务器发送请求。因为数据集和类避免了
XML属性,很容易将UniverseData
用于测试、开发和其他一切。
以下是我在某个时间点复制的更新频率(可能已更改):
players.xml -> daily
universe.xml -> weekly
highscore.xml -> hourly
alliances.xml -> daily
serverData.xml -> daily
playerData.xml -> weekly
localization.xml -> static
universes.xml -> static
也许最简单的方法是使用requests_cache。在
import requests_cache
requests_cache.install_cache('demo_cache')
问题/想法
。。。受到普遍欢迎。节省我们的时间。 而且,整体设计还远不够理想。 拉请求欢迎。一定要包括测试。在
- 项目
标签: