1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
""" |
3
|
|
|
cron: 21 */6 * * * |
4
|
|
|
new Env('Hax'); |
5
|
|
|
""" |
6
|
|
|
|
7
|
|
|
from random import choice |
8
|
|
|
|
9
|
|
|
import requests |
10
|
|
|
from bs4 import BeautifulSoup |
11
|
|
|
|
12
|
|
|
from notify_mtr import send |
13
|
|
|
from utils import get_data |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
class Hax: |
17
|
|
|
@staticmethod |
18
|
|
|
def get_ua(brower_name): |
19
|
|
|
url = "https://ghproxy.com/https://raw.githubusercontent.com/Oreomeow/checkinpanel/master/user-agent.json" |
20
|
|
|
useragent = choice(requests.get(url).json()[brower_name]) |
21
|
|
|
return useragent |
22
|
|
|
|
23
|
|
|
def check(self, url): |
24
|
|
|
headers = { |
25
|
|
|
"User-Agent": self.get_ua("Safari"), |
26
|
|
|
"Content-type": "application/json", |
27
|
|
|
} |
28
|
|
|
datas = requests.get(url, headers=headers).text |
29
|
|
|
return datas |
30
|
|
|
|
31
|
|
|
def get_server_info(self): |
32
|
|
|
html_text = self.check("https://hax.co.id/server") |
33
|
|
|
soup = BeautifulSoup(html_text, "html.parser") |
34
|
|
|
zone_tags = soup("h5", class_="card-title mb-4") |
35
|
|
|
sum_tags = soup("h1", class_="card-text") |
36
|
|
|
vps_dict = dict(map(lambda x, y: [x.text, y.text], zone_tags, sum_tags)) |
37
|
|
|
return vps_dict |
38
|
|
|
|
39
|
|
|
def check_data_center(self, data_center): |
40
|
|
|
html_text = self.check("https://hax.co.id/create-vps") |
41
|
|
|
soup = BeautifulSoup(html_text, "html.parser") |
42
|
|
|
if soup.find("option", value=data_center): |
43
|
|
|
return True |
44
|
|
|
else: |
45
|
|
|
return None |
46
|
|
|
|
47
|
|
|
def main(self): |
48
|
|
|
msg = "" |
49
|
|
|
vps_dict = self.get_server_info() |
50
|
|
|
for k, v in vps_dict.items(): |
51
|
|
|
msg += str(k) + "\t" + str(v) + "\n" |
52
|
|
|
has_eu_mid1 = self.check_data_center("EU Middle Specs") |
53
|
|
|
msg += ( |
54
|
|
|
"EU Middle Specs (KVM + SSD) are NOT available now.\t暂时没有库存。" |
55
|
|
|
if not has_eu_mid1 |
56
|
|
|
else "CHECK https://hax.co.id/create-vps NOW!!! EU Middle Specs (KVM + SSD) are available now.\t有库存!。" |
57
|
|
|
) |
58
|
|
|
return msg |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
if __name__ == "__main__": |
62
|
|
|
data = get_data() |
63
|
|
|
hax = data.get("HAX") |
64
|
|
|
if hax: |
65
|
|
|
res = Hax().main() |
66
|
|
|
send("Hax", res) |
67
|
|
|
|