44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import httpx
|
|
import asyncio
|
|
import sqlite3
|
|
import json
|
|
|
|
url = 'http://94.177.199.207:3000/client'
|
|
session = 'AssistenzaPubblicaBardiProd'
|
|
|
|
async def fetch(client, url):
|
|
response = await client.get(url)
|
|
return response.json()
|
|
|
|
def getContactList():
|
|
api = f'{url}/getContacts/{session}'
|
|
with httpx.Client() as client:
|
|
response = client.get(api)
|
|
return response.json()
|
|
|
|
async def main():
|
|
contactList = getContactList()
|
|
|
|
print(type(contactList))
|
|
|
|
'''
|
|
async with httpx.AsyncClient() as client:
|
|
tasks = fetch(client, url)
|
|
results = await asyncio.gather(*tasks)
|
|
for result in results:
|
|
print(result)
|
|
'''
|
|
for contact in contactList["contacts"]:
|
|
print("\nDettagli contatto:")
|
|
print(f"Numero: {contact.get('number', 'N/A')}")
|
|
print(f"Nome: {contact.get('name', 'N/A')}")
|
|
print(f"Pushname: {contact.get('pushname', 'N/A')}")
|
|
print(f"ShortName: {contact.get('shortName', 'N/A')}")
|
|
print(f"Server ID: {contact['id']['server']}")
|
|
print(f"User ID: {contact['id']['user']}")
|
|
print(f"serialized: {contact['id']['_serialized']}")
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|
|
|