Spaces:
Running
Running
alptangall
commited on
Commit
•
018c5c4
1
Parent(s):
64891bd
Create acb.py
Browse files
acb.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
from bs4 import BeautifulSoup as Bs4
|
3 |
+
import time
|
4 |
+
import os
|
5 |
+
import datetime
|
6 |
+
import random,json
|
7 |
+
from urllib.parse import unquote
|
8 |
+
import aiohttp
|
9 |
+
import base64,re
|
10 |
+
|
11 |
+
async def login(user,password):
|
12 |
+
url='https://apiapp.acb.com.vn/mb/v2/auth/tokens'
|
13 |
+
data={
|
14 |
+
"username":user,
|
15 |
+
"password": password,
|
16 |
+
"clientId": "iuSuHYVufIUuNIREV0FB9EoLn9kHsDbm"
|
17 |
+
}
|
18 |
+
headers={
|
19 |
+
'user-agent':'ACB-MBA/5 CFNetwork/1325.0.1 Darwin/21.1.0'
|
20 |
+
}
|
21 |
+
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
|
22 |
+
async with session.post(url,headers=headers,json=data) as res:
|
23 |
+
if res.status<400:
|
24 |
+
js=await res.json()
|
25 |
+
headers['authorization']='Bearer '+js['refreshToken']
|
26 |
+
refreshTk=js['refreshToken']
|
27 |
+
url='https://apiapp.acb.com.vn/mb/v2/auth/refresh'
|
28 |
+
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
|
29 |
+
async with session.post(url,headers=headers) as res:
|
30 |
+
url='https://apiapp.acb.com.vn/mb/legacy/ss/cs/bankservice/transfers/list/account-payment'
|
31 |
+
if res.status<400:
|
32 |
+
js=await res.json()
|
33 |
+
headers['authorization']='Bearer '+js['accessToken']
|
34 |
+
print(user+' login success')
|
35 |
+
return {'headers':headers,'refreshTk':refreshTk,'username':user}
|
36 |
+
return False
|
37 |
+
async def getRefreshTk(headers):
|
38 |
+
url='https://apiapp.acb.com.vn/mb/auth/refresh'
|
39 |
+
headers['authorization']='Bearer '+headers['refreshTk']
|
40 |
+
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
|
41 |
+
async with session.post(url,headers=headers) as res:
|
42 |
+
if res.status<400:
|
43 |
+
js=await res.json()
|
44 |
+
headers['authorization']='Bearer '+js['accessToken']
|
45 |
+
print(headers['username']+' get refresh token success')
|
46 |
+
return {headers['']+'headers':headers,'refreshTk':headers['refreshTk'],'username':headers['username']}
|
47 |
+
async def getListAccount(headers):
|
48 |
+
url='https://apiapp.acb.com.vn/mb/legacy/ss/cs/bankservice/transfers/list/account-payment'
|
49 |
+
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
|
50 |
+
async with session.get(url,headers=headers['headers']) as res:
|
51 |
+
if res.status<400:
|
52 |
+
js=await res.json()
|
53 |
+
print(headers['username']+' get list account success')
|
54 |
+
return {'list':js['data']}
|
55 |
+
return False
|
56 |
+
async def getBalance(headers,id):
|
57 |
+
url='https://apiapp.acb.com.vn/mb/legacy/ss/cs/person/transaction-history/list?account=15895127&transactionType=&from=&to=&min=&max='
|
58 |
+
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
|
59 |
+
async with session.get(url,headers=headers['headers']) as res:
|
60 |
+
if res.status<400:
|
61 |
+
js=await res.json()
|
62 |
+
print(headers['username']+' get balance success')
|
63 |
+
return {
|
64 |
+
'data':js['data']
|
65 |
+
}
|
66 |
+
return False
|