pull down to refresh

Once you get a potential Bitcoin address, you need to see if it actually has funds. For that, there's no other way to get that information than from the Bitcoin blockchain.
One way of doing that is through an API that returns the summary of an address, where you would see if it has ever been used and the balance.
Looking up addresses summary/balance/history requires having an index of all of them (more than 1TB) to be fast. And some computing power to retrieve it.
There are public APIs such as the one from mempool.space The software is open source and you can also host your own instance. If you use the public one, you will only be able to perform a limited number of queries per unit of time (e.g., 10 requests per minute).
For the previous script, you would want to make as many as transactions per second as you can. And that's not feasible with a public instance.
Here is an example request. If you do enough requests fast, you will get rate limited: the server will stop responding requests from your IP.
curl -sSL "https://mempool.space/api/address/bc1qhm9gr74n4my0pk5fm36njgwpfyqf4ekmeplfjn" | jq
{
  "address": "bc1qhm9gr74n4my0pk5fm36njgwpfyqf4ekmeplfjn",
  "chain_stats": {
    "funded_txo_count": 1,
    "funded_txo_sum": 71813214,
    "spent_txo_count": 1,
    "spent_txo_sum": 71813214,
    "tx_count": 2
  },
  "mempool_stats": {
    "funded_txo_count": 0,
    "funded_txo_sum": 0,
    "spent_txo_count": 0,
    "spent_txo_sum": 0,
    "tx_count": 0
  }
}