├── requirements-keyiflerolsun.txt
├── requirements.txt
├── Screenshots
├── 1.jpg
├── 2.jpg
├── 3.jpg
└── keyiflerolsun.jpg
├── README.md
├── 5sim.py
└── keyiflerolsun.py
/requirements-keyiflerolsun.txt:
--------------------------------------------------------------------------------
1 | Kekik
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | requests==2.28.1
2 | xlwt==1.3.0
3 |
--------------------------------------------------------------------------------
/Screenshots/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gamedevfur/5simGetCheapestCountries/HEAD/Screenshots/1.jpg
--------------------------------------------------------------------------------
/Screenshots/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gamedevfur/5simGetCheapestCountries/HEAD/Screenshots/2.jpg
--------------------------------------------------------------------------------
/Screenshots/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gamedevfur/5simGetCheapestCountries/HEAD/Screenshots/3.jpg
--------------------------------------------------------------------------------
/Screenshots/keyiflerolsun.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gamedevfur/5simGetCheapestCountries/HEAD/Screenshots/keyiflerolsun.jpg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 5sim Get Cheapest Countries
2 | 
3 | 
4 | ## About
5 | This software uses to list cheapest priced countries by service
6 | ## How to use
7 | * As first run ```pip install -r requirements.txt``` command to install required libraries in your terminal
8 |
9 | * Run ```5sim.py``` and enter the service you want
10 |
11 | * After the process is complete, you can export the results to an Excel file
12 |
13 | ## Screenshots
14 |
15 |
16 |
17 |
18 |
19 | ## Licence
20 | [MIT](https://choosealicense.com/licenses/mit/)
21 |
--------------------------------------------------------------------------------
/5sim.py:
--------------------------------------------------------------------------------
1 | from requests import get
2 | from collections import OrderedDict
3 | from xlwt import Workbook
4 | from sys import path
5 | from os.path import join
6 |
7 | countries_data = get("https://5sim.net/v1/guest/countries").json()
8 |
9 | countries = {}
10 | for key, values in countries_data.items():
11 | countries[key] = {"Virtuals": [value for value in values.keys() if value.startswith("virtual")]}
12 |
13 | services = {}
14 | service_ask = input("Enter service: ").lower()
15 | print("Please Wait ...")
16 |
17 | for country, value in countries.items():
18 | virtualsPrices = {}
19 | sortedVirtualPrices = {}
20 | for virtual in value["Virtuals"]:
21 | products_data = get(f"https://5sim.net/v1/guest/products/{country}/{virtual}").json()
22 | if service_ask in products_data.keys():
23 | virtualsPrices[virtual] = {"Price": products_data[service_ask]["Price"], "Stock": products_data[service_ask]["Qty"]}
24 |
25 | sortedVirtualPrices = OrderedDict(sorted(virtualsPrices.items(),key=lambda kv: kv[1]["Price"],reverse=False))
26 | for virtual in sortedVirtualPrices:
27 | if sortedVirtualPrices[virtual]["Stock"] != 0:
28 | services[country] = {"price": sortedVirtualPrices[virtual]["Price"], "stok": sortedVirtualPrices[virtual]["Stock"], "virtual": virtual}
29 | break
30 |
31 | sortedServices = OrderedDict(sorted(services.items(),key=lambda kv: kv[1]["price"],reverse=False))
32 | for service in sortedServices:
33 | print(service, f"Price :{sortedServices[service]['price']}", f"Stock :{sortedServices[service]['stok']}", f"Virtual :{sortedServices[service]['virtual']}")
34 |
35 | excel_ask = input("Do you want export to Excel file ? (Y/N) :").lower()
36 | if excel_ask == "y":
37 | wb = Workbook()
38 | ws = wb.add_sheet("Sheet 1")
39 | for row, service in enumerate(sortedServices):
40 | ws.write(row,0,service)
41 | ws.write(row,1,sortedServices[service]["price"])
42 | ws.write(row,2,sortedServices[service]["stok"])
43 | ws.write(row,3,sortedServices[service]["virtual"])
44 | print(join(path[0], "5sim.xls"))
45 | wb.save(join(path[0], "5sim.xls"))
46 | print("Exported to 5sim.xls")
47 | input("Press Enter to exit")
--------------------------------------------------------------------------------
/keyiflerolsun.py:
--------------------------------------------------------------------------------
1 | # Bu araç @keyiflerolsun tarafından | @KekikAkademi için yazılmıştır.
2 |
3 | from rich import print
4 | from asyncio import run, sleep, Semaphore, create_task, gather
5 | from aiohttp import ClientSession
6 | from atexit import register as kapatirken
7 |
8 | class SimNet:
9 | def __oturum_kapa(self):
10 | run(self.oturum.close())
11 |
12 | def __init__(self):
13 | self.oturum = ClientSession()
14 | kapatirken(self.__oturum_kapa)
15 | self.__limit = Semaphore(50)
16 |
17 | async def __ulkeler_ve_hatlar(self) -> dict[str, list[str]]:
18 | async with self.oturum.get("https://5sim.net/v1/guest/countries") as istek:
19 | ulkeler_veri = await istek.json()
20 |
21 | return {
22 | ulke: [key for key in detay.keys() if key.startswith("virtual")]
23 | for ulke, detay in ulkeler_veri.items()
24 | }
25 |
26 | async def __hat_fiyat_ver(self, ulke:str, hat:str, hizmet:str="telegram") -> dict | None:
27 | async with self.__limit:
28 | if self.__limit.locked():
29 | await sleep(1)
30 |
31 | while True:
32 | try:
33 | async with self.oturum.get(f"https://5sim.net/v1/guest/products/{ulke}/{hat}") as istek:
34 | hizmetler_veri = await istek.json()
35 | break
36 | except Exception:
37 | await sleep(.1)
38 |
39 | return {
40 | "hat" : hat,
41 | "fiyat" : hizmetler_veri[hizmet]["Price"],
42 | "adet" : hizmetler_veri[hizmet]["Qty"]
43 | } if hizmet in hizmetler_veri.keys() else None
44 |
45 | async def __ulke_fiyatlari(self, ulke:str, hatlar:str, hizmet:str) -> dict | None:
46 | hat_fiyatlari = []
47 | for hat_bilgi in await gather(*(create_task(self.__hat_fiyat_ver(ulke, hat, hizmet)) for hat in hatlar)):
48 | if hat_bilgi and hat_bilgi["adet"] > 0:
49 | hat_fiyatlari.append(hat_bilgi)
50 |
51 | return {ulke: sorted(hat_fiyatlari, key=lambda sozluk: sozluk["fiyat"])} if hat_fiyatlari else None
52 |
53 | async def en_ucuz_hatlar(self, hizmet:str="telegram"):
54 | ulkeler_ve_hatlar = await self.__ulkeler_ve_hatlar()
55 |
56 | for ulke, hatlar in ulkeler_ve_hatlar.items():
57 | veri = await self.__ulke_fiyatlari(ulke, hatlar, hizmet)
58 | if veri:
59 | yield veri
60 |
61 | from asyncio import new_event_loop
62 | from Kekik.cli import konsol, temizle
63 |
64 | async def ana_fonksiyon(hizmet:str):
65 | temizle()
66 |
67 | print(f"\n\n\t\t[yellow]5Sim.Net {hizmet.title()} için En Ucuz Hatlar\n\n")
68 |
69 | print(f"[green1]{'Ülke':^23} [red]|[/] [turquoise2]{'Hat Adı':>10} [red]|[/] [green3]{'Fiyat':^8} [red]|[/] [yellow4]{'Adet':<8}")
70 | print(f"[green1]{'----':^23} [red]|[/] [turquoise2]{'-------':>10} [red]|[/] [green3]{'-----':^8} [red]|[/] [yellow4]{'----':<8}\n")
71 |
72 | sim_net = SimNet()
73 |
74 | en_ucuz_hatlar = []
75 | async for veri in sim_net.en_ucuz_hatlar(hizmet.lower()):
76 | for ulke, hatlar in veri.items():
77 | en_ucuz_hat = {
78 | "ulke" : ulke,
79 | "hat" : hatlar[0]["hat"], # * 0 En Ucuz » -1 En Pahalı
80 | "fiyat" : hatlar[0]["fiyat"], # * 0 En Ucuz » -1 En Pahalı
81 | "adet" : hatlar[0]["adet"] # * 0 En Ucuz » -1 En Pahalı
82 | }
83 | break
84 |
85 | en_ucuz_hatlar.append(en_ucuz_hat)
86 |
87 | print(f"[green1]{en_ucuz_hat['ulke']:^23} [red]|[/] [turquoise2]{en_ucuz_hat['hat']:>10} [red]|[/] [green3]{en_ucuz_hat['fiyat']:^8} [red]|[/] [yellow4]{en_ucuz_hat['adet']:<8}")
88 |
89 | temizle()
90 | sirali_liste = sorted(en_ucuz_hatlar, key=lambda sozluk: sozluk["fiyat"])
91 |
92 | print("\n\n\t\t[yellow]5Sim.Net Telegram için En Ucuz Hatlar\n\n")
93 |
94 | print(f"[green1]{'Ülke':^23} [red]|[/] [turquoise2]{'Hat Adı':>10} [red]|[/] [green3]{'Fiyat':^8} [red]|[/] [yellow4]{'Adet':<8}")
95 | print(f"[green1]{'----':^23} [red]|[/] [turquoise2]{'-------':>10} [red]|[/] [green3]{'-----':^8} [red]|[/] [yellow4]{'----':<8}\n")
96 |
97 | for en_ucuz_hat in sirali_liste:
98 | print(f"[green1]{en_ucuz_hat['ulke']:^23} [red]|[/] [turquoise2]{en_ucuz_hat['hat']:>10} [red]|[/] [green3]{en_ucuz_hat['fiyat']:^8} [red]|[/] [yellow4]{en_ucuz_hat['adet']:<8}")
99 |
100 | if __name__ == "__main__":
101 | hizmet = konsol.input("\n\n[magenta]Hangi Hizmet İçin EN Ucuz Ülkeler Gelsin? (Örn.: Telegram): ")
102 | loop = new_event_loop()
103 | loop.run_until_complete(ana_fonksiyon(hizmet))
--------------------------------------------------------------------------------