-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpbb.py
48 lines (35 loc) · 1.32 KB
/
phpbb.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
#!/usr/bin/env python3
import subprocess
import feedparser
import html
import requests
from requests.packages import urllib3
# --------------------------------------------------------------------------------
# vpn_id='nl-170068'
url = "" # Ссылка на rss/atom
quantity = 3 # Количество выводимых ответов
output_len = 50 # Длина выводимой строки
# --------------------------------------------------------------------------------
command = f"nmcli c show --active"
active_connections = subprocess.check_output(command, shell=True)
if b'vpn' not in active_connections:
exit()
try:
urllib3.disable_warnings(category=urllib3.exceptions.InsecureRequestWarning)
response = requests.get(url=url, verify=False, timeout=5)
except Exception:
exit()
output = [f'${{voffset 5}}$hr${{voffset 5}}',]
feeds = feedparser.parse(response.content)
counter = 1
for feed in feeds.entries:
dateTime = html.unescape(feed.updated)
dateTime = dateTime.split('+')[0]
dateTime = dateTime.replace('T', ' ')
dateTime = dateTime[5:-3]
line = f'{dateTime} | {feed.author} | {feed.title}'
output.append(line[:output_len])
counter += 1
if counter > quantity:
break
print('\n'.join(output))