-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_gazelle.py
49 lines (44 loc) · 1.93 KB
/
check_gazelle.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
import requests
from lxml import html
import misc
from credentials import telegram
register_closed = (
'Registration Closed', # All
'注册关闭' # DICmusic
)
application_closed = (
'Applications are currently closed.', # AwesomeHD
'你刚刚试图查看不存在的页面。' # DICmusic
)
for item in misc.trackers.values():
register = requests.get(f'{item}/register.php')
# Проверяем, что не было переадресации и ресурс доступен
if register.url == f'{item}/register.php' and register.status_code == 200:
parser = html.fromstring(register.text)
text = parser.xpath('//title/text()')[0]
# Если шаблоного текста нет - отправляем сообщение
status = text.startswith(register_closed)
if status is False:
requests.post(
f"https://api.telegram.org/{telegram['bot_id']}:{telegram['bot_token']}/sendMessage",
json={
'chat_id': telegram['chat_id'],
'text': f'{register.url}\n{text}'
}
)
application = requests.get(f'{item}/application.php')
if application.url == f'{item}/application.php' and application.status_code == 200:
parser = html.fromstring(application.text)
test = parser.xpath('//div/p/text()')
# Так как BroadcasTheNet другая разметка страницы, мы его пока выкидываем
if test:
text = text[0]
status = text.startswith(application_closed)
if status is False:
requests.post(
f"https://api.telegram.org/{telegram['bot_id']}:{telegram['bot_token']}/sendMessage",
json={
'chat_id': telegram['chat_id'],
'text': f'{application.url}\n{text}'
}
)