26 lines
808 B
Python
26 lines
808 B
Python
from xml.etree import ElementTree
|
|
|
|
from aiohttp import ClientSession
|
|
|
|
|
|
async def tk_balance(card_number: int):
|
|
async with ClientSession() as session:
|
|
response = await session.post(
|
|
url="https://transkart.ru/api/payment/checkCard",
|
|
json={
|
|
"card": card_number
|
|
}
|
|
)
|
|
await session.close()
|
|
text = await response.text()
|
|
file = open("temp.xml", "w+")
|
|
file.write(text)
|
|
file.close()
|
|
try:
|
|
balance = ElementTree.parse("temp.xml").findtext(".//pbtext").replace("Билет длительного пользования", "").replace(" руб.", "")
|
|
except AttributeError:
|
|
return
|
|
if not balance:
|
|
return
|
|
return int(balance)
|