1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
""" |
3
|
|
|
cron: 21 */6 * * * |
4
|
|
|
new Env('Hax'); |
5
|
|
|
""" |
6
|
|
|
|
7
|
|
|
import re |
8
|
|
|
from random import choice |
9
|
|
|
|
10
|
|
|
import requests |
11
|
|
|
from bs4 import BeautifulSoup |
12
|
|
|
|
13
|
|
|
from notify_mtr import send |
14
|
|
|
from utils import get_data |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
class Hax: |
18
|
|
|
@staticmethod |
19
|
|
|
def get_ua(brower_name): |
20
|
|
|
url = "https://ghproxy.com/https://raw.githubusercontent.com/Oreomeow/checkinpanel/master/user-agent.json" |
21
|
|
|
useragent = choice(requests.get(url).json()[brower_name]) |
22
|
|
|
return useragent |
23
|
|
|
|
24
|
|
|
def check(self, url): |
25
|
|
|
headers = { |
26
|
|
|
"User-Agent": self.get_ua("Safari"), |
27
|
|
|
"Content-type": "application/json", |
28
|
|
|
} |
29
|
|
|
datas = requests.get(url, headers=headers).text |
30
|
|
|
return datas |
31
|
|
|
|
32
|
|
|
def get_server_info(self): |
33
|
|
|
html_text = self.check("https://hax.co.id/data-center") |
34
|
|
|
soup = BeautifulSoup(html_text, "html.parser") |
35
|
|
|
zone_tags = soup("h5", class_="card-title mb-4") |
36
|
|
|
sum_tags = soup("h1", class_="card-text") |
37
|
|
|
vps_dict = dict(map(lambda x, y: [x.text, y.text], zone_tags, sum_tags)) |
38
|
|
|
return vps_dict |
39
|
|
|
|
40
|
|
|
def get_data_center(self): |
41
|
|
|
html_text = self.check("https://hax.co.id/create-vps") |
42
|
|
|
soup = BeautifulSoup(html_text, "html.parser") |
43
|
|
|
center_list = [x.text for x in soup("option", value=re.compile("^EU*"))] |
44
|
|
|
center_str = "\n".join(center_list) |
45
|
|
|
return center_list, center_str |
46
|
|
|
|
47
|
|
|
def main(self): |
48
|
|
|
vps_dict = self.get_server_info() |
49
|
|
|
vps_str = "" |
50
|
|
|
for k, v in vps_dict.items(): |
51
|
|
|
vps_str += str(k) + "\t" + str(v) + "\n" |
52
|
|
|
srv_stat = f"[🛰Opened Server Statistics / 已开通的服务器数据]\n{vps_str}\n\n" |
53
|
|
|
center_list, center_str = self.get_data_center() |
54
|
|
|
data_center = ( |
55
|
|
|
f"[🚩Currently available data centers / 当前可以开通的数据中心]\n{center_str}\n\n" |
56
|
|
|
) |
57
|
|
|
eu_mid1 = ( |
58
|
|
|
"[♨Special Focus / 特别关注]\nEU Middle Specs (KVM + SSD) are NOT available now.\t暂时没有库存。" |
59
|
|
|
if "EU Middle Specs" not in center_list |
60
|
|
|
else "CHECK https://hax.co.id/create-vps NOW!!! EU Middle Specs (KVM + SSD) are available now.\t有库存!。" |
61
|
|
|
) |
62
|
|
|
msg = srv_stat + data_center + eu_mid1 |
63
|
|
|
return msg |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
if __name__ == "__main__": |
67
|
|
|
data = get_data() |
68
|
|
|
hax = data.get("HAX") |
69
|
|
|
if hax: |
70
|
|
|
res = Hax().main() |
71
|
|
|
send("Hax", res) |
72
|
|
|
|