diff options
-rw-r--r-- | scrap.py | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -88,8 +88,32 @@ def expand_hashes(snapshot): Expands killmails in *snapshot* IN PLACE by adding their hash based on information from Zkillboard. """ for killmail in snapshot["killmails"]: - killmail["hash"] = get_hash(killmail["id"]) time.sleep(1.05) # Zkillboard is very sensitive. + killmail["hash"] = get_hash(killmail["id"]) + return snapshot + + +def get_details(kill, hash): + """ + Retrieves detailed information about killmail from EVE ESI using killmail's *kill* ID and *hash*. + """ + query = "https://esi.evetech.net/latest/killmails/{}/{}/?datasource=tranquility" + response = requests.get(query.format(kill, hash)) + response.raise_for_status() + return response.json() + + +def expand_details(snapshot): + """ + Expands killmails in *snapshot* IN PLACE by adding details from EVE ESI. Some data is dropped in process as e.g., + full information on attackers is not important in context of the visualizations. + """ + for killmail in snapshot['killmails']: + details = get_details(killmail['id'], killmail['hash']) + del details['attackers'] + del details['victim']['items'] + del details['victim']['damage_taken'] + killmail.update(details) return snapshot @@ -113,6 +137,7 @@ def main(): args = parser.parse_args() snapshot = get_related_kills(args.url) expand_hashes(snapshot) + expand_details(snapshot) filename = output_name(args) with open(filename, "w") as fd: opts = {'indent': 4} if args.pretty else {} |