RE: RE: HIVE FEST 2022 AMSTERDAM - That Was AMAZING!
You are viewing a single comment's thread from:

RE: HIVE FEST 2022 AMSTERDAM - That Was AMAZING!

pibara(67)
Published in
HiveFest
Words
64
Reading
1 min
Listen
Play
4y

A little bit of non-working code you guys might use as a start for figuring out how to find dutch users:

#!/usr/bin/python3
import sys
import json
from lighthive.client import Client

def get_all_account_names(client):
    acc0 = ""
    while True:
        accounts = client.lookup_accounts(acc0,16)
        if acc0:
            yield accounts[1:]
        else:
            yield accounts
        if not accounts or len(accounts) == 1:
            return
        acc0 = accounts[-1]

def get_account_basinifo(client, accounts):
    for account in client.get_accounts(accounts):
        if (account["last_vote_time"][:4] == "2022" or account["last_post"][:4] == "2022") and "{" in account["json_metadata"]:
            try:
                data = json.loads(account["json_metadata"])
                if "location" in data:
                    yield [account["name"], data["location"]]
                else:
                    yield [account["name"], None]
            except:
                pass


c = Client()
for accountchunk in get_all_account_names(c):
    for account_info in get_account_basinifo(c, accountchunk):
        print(account_info)

The code looks for active accounts (posted or voted this year) that have json_metadata. It then looks for location, an aparently rarely used key. The code needs work, but with some tuning it could be a start for your efforts.

Hope this helps.

@pibara: A little bit | Ecency