import requests import sys import os class Allocator: def __init__(self): self.callers = {"facebook":"12133750939","tiktok":"14322861275","microsoft8":"18553308653","payoneer":"19172677299","microsoft4":"14256352970"} self.arguments = sys.argv[1:] if sys.argv[1:] else None self.cli = self._get_cli() self.number_of_allocations = self._get_number_of_interactions() self.headers_get = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Language': 'en-US,en;q=0.5', # 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Referer': 'https://www.truecallers.net/apps/caller_access', 'X-Requested-With': 'XMLHttpRequest', 'Connection': 'keep-alive', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Priority': 'u=0', } self.headers_post = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0', 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', # 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Referer': 'https://www.truecallers.net/test/numbers', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-CSRF-TOKEN': 'tla0hsODgeurRxZSU8AXjuGaZpTgsIRymOYvnQnG', 'X-Requested-With': 'XMLHttpRequest', 'Origin': 'https://www.truecallers.net', 'Connection': 'keep-alive', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Priority': 'u=0', } self.cookies = { 'XSRF-TOKEN': 'eyJpdiI6IkEyWkdIRVB0YWNGZmVtWTlIWlRUd3c9PSIsInZhbHVlIjoiMHpxZFhoSU1TRnZCRFZUN2dCYTVGZzlrXC9kXC9IeWI5SGJRRjJwRFBTc2p6cTczSTlqSnFXUlZPOTV5RzlqUkp1MHdBN0ZTZHUyU2lUQXdKd084S0hwOHJNNEtTNlBrdVhEWkM4ZktoYXA3bkgyNkZtaTZJK0VGZlFOekRhbUJXQiIsIm1hYyI6ImUyZTJlNDI5NDZjYjg1ZTY0NDhhYTYyMDE1MTE5ZjAzYzQ3YjUwYmQyOWVkMmQ0NzE2MTU5OWM1MDJmMjY1YzMifQ%3D%3D', 'truecallers_user_session': 'eyJpdiI6IjhDY0RwdFlmaUlBRG1jR1Y5RU1RaVE9PSIsInZhbHVlIjoidzRuVk9XU0EwWGRtWkFFVTIwRTU3ZHdkTlFabFFHV0tJdWpGeDRBN0xxaEsxQ2JETzdKSThRT0E4RWpqbld1bHJuQ3djRDZDVE1lMlp2UTc2VEI3RFpVa1R0K3lnQ0t1d1lcL3VQVkVUWEF4UkZsaVwvbTF4bk1kalVuM1VBSStlaSIsIm1hYyI6ImZhNmU4YzIxYmQ4NDM1ODYwYjU1ODExZGYxNmVlODkyZDJhZDZkZmEzOTA1NjQzOTkyMGM4ZTJjZmM3M2I1NTcifQ%3D%3D', '_ga_P8J382F0E8': 'GS1.1.1725236478.90.1.1725238197.0.0.0', '_ga': 'GA1.1.706384925.1723906927', 'std_uuid': 'eyJpdiI6ImorMTc2XC9SWFwvWStjSVRITUdXOXcwdz09IiwidmFsdWUiOiI5WWl0M2pCdlR3M1BxZGpaMzlNZVJ6dUhQS2J1Wjg1bUxJS2NlTlowbVBITGhGVEVBS2VIcm5tNGM3bVJ6bGZcLyIsIm1hYyI6ImNkOTNjZGMwMDJlMzk2MGI5ZDVkYmY0MDBhZjYzM2JiNzI2YzkyNDY0MGE2MGZiMmFhYTg0YWYzMjZhNGE3NjUifQ%3D%3D', '_gid': 'GA1.2.2074001507.1725236480', 'cf_clearance': 'zrq_EV7yALPPqa9JX0v4eNpGYWesaA0GR5gZs6nI2yU-1725236565-1.2.1.1-op0dTEkOw__72FFtoTt8r3YuRdCgridZ0Cd32yVZl9PlM_nazmWjMfb_xlTq4C_k3YyV2K0ND99qHwVJSKLryg37jCT021XfxbfYyGB3CSr4kVU3d7d4CTSz71wlU1GzGQt.UpJrDuenJjKTPtnzD_BvDwHJ91m0BjH8z_BDkA_F1mdYohFvZAdi3qGFWluI1C56zCrVSzQYY0dxtWlyMK1WHnsm27.NwOWKwZxIgyntxs3VpoY1KHj7DFt0o34O3JDBgbDLIjqjmUCQpxFyBjaQK9Hf.6B0sGgjvx0CkuxuUtAmbPgQzOlTj0bRU2EcfBRoTf6_e824yQisz0r1Jw', } def _get_cli(self): return [i for i in self.arguments if self.arguments.index(i) %2 == 0] def _get_number_of_interactions(self): return [i for i in self.arguments if i not in self.cli] def _get_params(self,cli): return { 'draw': '3', 'columns[0][data]': 'access_origin', 'columns[0][name]': 'access_origin', 'columns[0][searchable]': 'true', 'columns[0][orderable]': 'true', 'columns[0][search][value]': '', 'columns[0][search][regex]': 'false', 'columns[1][data]': 'caller', 'columns[1][name]': 'caller', 'columns[1][searchable]': 'true', 'columns[1][orderable]': 'true', 'columns[1][search][value]': '', 'columns[1][search][regex]': 'false', 'columns[2][data]': 'termination', 'columns[2][name]': 'termination', 'columns[2][searchable]': 'true', 'columns[2][orderable]': 'true', 'columns[2][search][value]': '', 'columns[2][search][regex]': 'false', 'columns[3][data]': 'test_number', 'columns[3][name]': 'test_number', 'columns[3][searchable]': 'true', 'columns[3][orderable]': 'true', 'columns[3][search][value]': '', 'columns[3][search][regex]': 'false', 'columns[4][data]': 'latest_call_time', 'columns[4][name]': 'latest_call_time', 'columns[4][searchable]': 'true', 'columns[4][orderable]': 'true', 'columns[4][search][value]': '', 'columns[4][search][regex]': 'false', 'start': '0', 'length': '-1', 'search[value]': '', 'search[regex]': 'false', 'cli': f"{cli}", '_': '1725236564570', } def data(self,prefix,carrier_id): return { 'carrier_id': carrier_id, 'prefix': prefix, 'allocate_number': '300', 'term': '1', } def get_allocations(self,cli): lista = [] response = requests.get('https://www.truecallers.net/apps/caller_access', params=self._get_params(cli=cli), cookies=self.cookies, headers=self.headers_get) # print("Data :",response.json()) data = response.json().get("data") for d in data: prefix = d.get("termination").split("-")[-1] carrier_id = d.get("carrier_id") lista.append((prefix,carrier_id)) # print(lista) return lista def launch_allocation(self,allocation): prefix,carrier_id = allocation response = requests.post('https://www.truecallers.net/test/allocate_numbers', cookies=self.cookies, headers=self.headers_post, data=self.data(prefix=prefix,carrier_id=carrier_id)) # print(response.json()) status = response.status_code message = response.json()["message"] print(status) print(message) return (status,message) def manual_allocation(self,allocation): self.launch_allocation(allocation) # alloc = Allocator() # for i,number in zip(alloc.cli,alloc.number_of_allocations): # caller_number = alloc.callers[i] # allocations = alloc.get_allocations(caller_number) # for n in range(int(number)): # allocation = allocations[n] # print(allocation) # alloc.launch_allocation(allocation=allocation) from allocations import Allocator import os import requests from requests.exceptions import JSONDecodeError import time class Perma(Allocator): def __init__(self,path): super().__init__() self.path = os.path.abspath(path) self.headers_get_id = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Language': 'en-US,en;q=0.5', 'Referer': 'https://www.truecallers.net/user/numbers', 'X-Requested-With': 'XMLHttpRequest', 'Connection': 'keep-alive', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Priority': 'u=0', } self.cookies_get_id = { 'XSRF-TOKEN': 'eyJpdiI6IkRxa1h2Q3I2b1lvUGx5NjV0MTlTRnc9PSIsInZhbHVlIjoieXo5eCs0TFpETXo3cVwvOUh5TU56aDlcL1pmeE15SnNkT3A1YURVZE1oejRzc2w2XC9HMTQzclwvOGRwVHN2NjVIMGNmODJmWWxYMmNmenlSTXdDOVhQRzFIVFlWbE5JVjQ5RG1vcUJWN0ZwazAyRDhMVjUwN3Q4eUR0MU5DV25YbzRJIiwibWFjIjoiMzU1OTFmOGIyMjk1YzY2YjA2NmEzZmMwMmZjYTI4NTM1ZmVjYzQxNzg3ZTdmNzNlYjU5NjRmMGQyNGY3N2IxYyJ9', 'truecallers_user_session': 'eyJpdiI6IjVXV3BXT3g3YVBP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b7g8ktyAmqdYOLVF7wcQRKAhVQw', } self.params_get_id = { 'draw': '3', 'columns[0][data]': 'c_range', 'columns[0][name]': 'c_range', 'columns[0][searchable]': 'false', 'columns[0][orderable]': 'false', 'columns[0][search][value]': '', 'columns[0][search][regex]': 'false', 'columns[1][data]': 'number', 'columns[1][name]': 'number', 'columns[1][searchable]': 'false', 'columns[1][orderable]': 'true', 'columns[1][search][value]': '', 'columns[1][search][regex]': 'false', 'columns[2][data]': 'created_at', 'columns[2][name]': 'created_at', 'columns[2][searchable]': 'false', 'columns[2][orderable]': 'true', 'columns[2][search][value]': '', 'columns[2][search][regex]': 'false', 'columns[3][data]': 'return_after', 'columns[3][name]': 'return_after', 'columns[3][searchable]': 'false', 'columns[3][orderable]': 'true', 'columns[3][search][value]': '', 'columns[3][search][regex]': 'false', 'columns[4][data]': 'term', 'columns[4][name]': 'term', 'columns[4][searchable]': 'false', 'columns[4][orderable]': 'false', 'columns[4][search][value]': '', 'columns[4][search][regex]': 'false', 'columns[5][data]': 'last_call', 'columns[5][name]': 'last_call', 'columns[5][searchable]': 'true', 'columns[5][orderable]': 'true', 'columns[5][search][value]': '', 'columns[5][search][regex]': 'false', 'columns[6][data]': 'ivr', 'columns[6][name]': 'ivr', 'columns[6][searchable]': 'false', 'columns[6][orderable]': 'false', 'columns[6][search][value]': '', 'columns[6][search][regex]': 'false', 'columns[7][data]': 'rate', 'columns[7][name]': 'rate', 'columns[7][searchable]': 'true', 'columns[7][orderable]': 'true', 'columns[7][search][value]': '', 'columns[7][search][regex]': 'false', 'columns[8][data]': 'actions', 'columns[8][name]': 'global.actions', 'columns[8][searchable]': 'false', 'columns[8][orderable]': 'false', 'columns[8][search][value]': '', 'columns[8][search][regex]': 'false', 'start': '0', 'length': '2400', 'search[value]': '', 'search[regex]': 'false', 'range': 'none', 'status': 'none', '_': '1726243392519', } self.cookies_delete = { 'XSRF-TOKEN': 'eyJpdiI6IjNXRVBnR21Sdk1vUk5BWHYyZk5Cd0E9PSIsInZhbHVlIjoiSTBhdnYzVCtYVDlkVWxlVWx0NlFUOUYwM1hURjNreVlKSGdmc0ZOUWpzaWpDK1RRTUhDelVndEFFNXhHUFBPeUNqUkQwNTRzZGdnVGZmK2ZcL09YdDNSWVord0lZcWNTVXVOYVI2dDZZdloyQXhPemgzem5nUFdBVW43MHpFXC9xTSIsIm1hYyI6IjAxOTgwZjM0YTVkM2QwNTM5MWM3OWEyZTRiZGU3ZjFkMDhlM2U5ZDQ5NWM4ODU3ZTNlMmU4ZTU4YzczNWNjNTUifQ%3D%3D', 'truecallers_user_session': 'eyJpdiI6Ik9Zc09SbUg4bWJ2NGZrc0JWRTJVRkE9PSIsInZhbHVlIjoiN2xmaTJyZ0lxRlM0cVlmcE1zdHViS1UrVHVNenZzYW00TFhpZklQbUdcL1hoc25EbTRsbExOelJ1SEhhVE1mYVl4c3VTRGpyYW9cL05SZCt4RFhSMGV1WmhPSjU4QzdPbDJoaTlEeWZaeGFpXC9NZVdnaE1cLzRTOXA1eGhkOUpPVk51IiwibWFjIjoiZTU5YTEyNDVhMGEwYTJiZTg3MGQ5MjEyYmE5YTgzMTg5NDYyNmJjYWFkMTU3YzQ5ZDI1ZjEyNDVhYmNmZDQ3YSJ9', '_ga_P8J382F0E8': 'GS1.1.1726184307.160.1.1726185908.0.0.0', '_ga': 'GA1.1.706384925.1723906927', 'std_uuid': 'eyJpdiI6Im9NZ0VySWhzbXdkSHhpWVo4S2lFZ0E9PSIsInZhbHVlIjoicENYV3FrajBLd01KZGpzcXF4MDVwSWczS29zQnpXQ2xUK2p1dFwvTFl1akpWa2dsXC9wRFV4UXRDNThHXC9KNStjeSIsIm1hYyI6IjlmN2U0YTA1NDUyNDdhY2ExMGRhYTljMmM3NjU1OTJkZTlmNjBiMjdjNDRlN2QwZGZmOTFhYTBiOTFjNzhmNjgifQ%3D%3D', '_gid': 'GA1.2.2074001507.1725236480', '_gat_gtag_UA_122571445_2': '1', 'cf_clearance': 'Y1w_FV5_lOAOxRypbsoA1KHRdzspemPTzj2JCQp03js-1726185908-1.2.1.1-DgCwuOEKaFkuSzhcoW_iSeimP8RmEs9MDYNcBG2qR1VPus4RS_RKeEEGHtUcFkSWq2PQfXY1XjBpHcNEn2uJLPYWSLqFnQt_BtD2VVnffMuAHd3Yf69U_kO6FZ.S6mtIMci6LM8stFZEa1uu8pecnaaUDDh2V5.vXB6cq_a5lynsTI9HN_PAgVehfNty6WcMPh9Wh9tLxkYqwvCHaJRfwRxUqVIxyntNXsodd5PQeW2poh9rWK7fxYl2MfssO.mhwYe328mFsqprFozfp6s9JuusMlH0EmHcQ0TYR33ZcsForjew5Apezr8xr0SjN_kpgDYTSG33KUeEtLEvH9E9Rg', } self.headers_delete = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0', 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'Referer': 'https://www.truecallers.net/user/numbers', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'x-csrf-token': 'tla0hsODgeurRxZSU8AXjuGaZpTgsIRymOYvnQnG', 'X-Requested-With': 'XMLHttpRequest', 'Origin': 'https://www.truecallers.net', 'Alt-Used': 'www.truecallers.net', 'Connection': 'keep-alive', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Priority': 'u=0', } def save_ids(self,list_id): if os.path.exists(self.path): with open(self.path,"a") as f: for id in list_id: # print("Writing..") f.write(f"{id}\n") else: with open(self.path,"w") as f: for id in list_id: f.write(str(id)+"\n") def delete_numbers(self,id_list): print(id_list) # print(id_list) data = { 'ids[]': id_list, '_method': 'DELETE', } if os.path.exists(self.path): with open(self.path,"r") as f: lines = [i.strip() for i in f.readlines()] response = requests.delete('https://www.truecallers.net/user/numbers/by_ids', cookies=self.cookies_delete, headers=self.headers_delete, data=data) print("Deleting ...",response.status_code) # print(response.json()) # s = response.status_code # if s == 204: # self.delete_from_file() def delete_from_file(self): if os.path.exists(self.path): with open(self.path,"w") as f: f.write("") def get_ids_from_file(self): if os.path.exists(self.path): with open(alloc.path,"r") as f: ids = [id.strip() for id in f.readlines()] return ids else: return [] def get_ids(self): lista = [] response = requests.get("https://www.truecallers.net/user/numbers",params=self.params_get_id,headers=self.headers_get_id,cookies=self.cookies_get_id) try: maps = response.json()["data"] # print("Maps...",maps) for i in maps: lista.append(i.get("id")) except JSONDecodeError as e: print(e) return lista def main(): alloc = Perma(path="./number_id.txt") ids = alloc.get_ids() print("IDS :",len(ids)) while len(ids) > 0: alloc.delete_numbers(id_list=ids) ids = alloc.get_ids() alloc.manual_allocation(("5025597","5717933")) alloc.manual_allocation (("26660960","5843589")) for i,number in zip(alloc.cli,alloc.number_of_allocations): caller_number = alloc.callers[i] allocations = alloc.get_allocations(caller_number) for n in range(int(number)): allocation = allocations[n] print(allocation) status,message = alloc.launch_allocation(allocation=allocation) print("Status ",status) if __name__ == "__main__": main()