-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvietnamobile.py
100 lines (96 loc) · 2.98 KB
/
vietnamobile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import requests
from bs4 import BeautifulSoup as Bs4
import time
import os
import datetime
import random,json
from urllib.parse import unquote
import aiohttp
import urllib3,re
import json
async def sendOtp(phone):
headers={
'user-agent':'Vietnamobile/4 CFNetwork/1325.0.1 Darwin/21.1.0',
'x-device-id':'BA7ABF14-BCC4-47EF-964F-DEF1B9E68541'
}
url='https://selfcare.vietnamobile.com.vn/api/account/register'
data={
'msisdn':'+84'+phone[1:]
}
print(data)
req=requests.post(url,headers=headers,json=data)
if req.status_code<400:
js=req.json()
if js['code']==None:
print(f'{phone} sent otp success')
return {'phone':phone,'transId':js['data']['transId']}
print(f'{phone} can\'t send otp')
return False
async def register(headers,otp):
headers['user-agent']='Vietnamobile/4 CFNetwork/1325.0.1 Darwin/21.1.0'
headers['x-device-id']='BA7ABF14-BCC4-47EF-964F-DEF1B9E68541'
url='https://selfcare.vietnamobile.com.vn/api/account/register/confirm'
data={
"transId": headers['transId'],
"otp": otp,
"password": "123123_Qwe"
}
print(headers)
#req=requests.post(url,headers=headers,json=data)
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
async with session.post(url,headers=headers,json=data) as res:
if res.status<400:
js=await res.json()
if js['code']==None:
print(f'{headers["phone"]} register success')
headers=headers|js['data']
return headers
'''if req.status_code<400:
js=req.json()
if js['code']==None:
print(f'{headers["phone"]} register success')
headers=headers|js['data']
return headers'''
print(f'{headers["phone"]} can\'t register')
return False
async def login(headers):
url='https://selfcare.vietnamobile.com.vn/api/auth/loginPassword'
header={
'user-agent':headers['user-agent'],
'x-device-id':headers['x-device-id']
}
data={
"msisdn": "+84"+headers['phone'][1:],
"password": "123123_Qwe"
}
req=requests.post(url,headers=header,json=data)
if req.status_code<400:
js=req.json()
if js['code']==None:
print(f'{headers["phone"]} login success')
headers['token']=js['data']['token']
return headers
print(f'{headers["phone"]} can\'t login')
return False
async def getInfo(headers):
url='https://selfcare.vietnamobile.com.vn/api/profile'
header={
'user-agent':headers['user-agent'],
'x-device-id':headers['x-device-id'],
'authorization':'Bearer '+headers['token']
}
req=requests.get(url,headers=header)
if req.status_code<400:
js=req.json()
if js['code']==None:
js=js['data']
url='https://selfcare.vietnamobile.com.vn/api/profile/personalInfo'
req=requests.get(url,headers=header)
if req.status_code<400:
js1=req.json()
if js1['code']==None:
js=js|js1['data']
print(f'{headers["phone"]} get information success')
return js
print(f'{headers["phone"]} can\'t get information')
return False