diff --git a/personal_data/fetchers/partisia_blockchain.py b/personal_data/fetchers/partisia_blockchain.py index 10527d5..d3ae59c 100644 --- a/personal_data/fetchers/partisia_blockchain.py +++ b/personal_data/fetchers/partisia_blockchain.py @@ -5,6 +5,7 @@ import re import json import secrets from decimal import Decimal +import email.utils import bs4 @@ -34,7 +35,7 @@ class MpcBalance(Scraper): deduplicate_mode = DeduplicateMode.ONLY_LATEST deduplicate_ignore_columns = ['account.update_time'] - def get_json(self, url: str, data: dict) -> tuple[dict,str]: + def get_json(self, url: str, data: dict) -> tuple[dict, datetime.datetime]: headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', @@ -42,7 +43,8 @@ class MpcBalance(Scraper): response = self.session.post(url, headers = headers, data=json.dumps(data)) response.raise_for_status() - date = response.headers.get('last-modified') or response.headers.get('date') + date_text = response.headers.get('last-modified') or response.headers.get('date') + date = email.utils.parsedate_to_datetime(date_text) json_data = response.json() if json_data is None: msg = 'No result data for ' + url @@ -64,11 +66,6 @@ class MpcBalance(Scraper): address = secrets.PBC_ACCOUNT_ADDRESS coins = self.determine_coins() - headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - } - url = URL_ACCOUNT_PLUGIN.format( hostname = HOSTNAME, shard = shard_id_for_address(address),