Last active
March 21, 2019 08:32
-
-
Save Elnee/8ec1e7133de4d64ea44c80169f67d731 to your computer and use it in GitHub Desktop.
Проверка счёта PeopleNet Украина и вывод уведомления в GNOME
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
import re | |
import gi | |
gi.require_version('Notify', '0.7') | |
from gi.repository import Notify | |
Notify.init('PeopleNet Account') | |
params = {'X_Username': 'your_username', 'X_Password': 'your_password'} | |
r = requests.post('http://my.people.net.ua/TSU/WWW/ACCOUNT_INFO/', data=params) | |
b = BeautifulSoup(r.content, 'html5lib') | |
account_status = (b.select('body > table:nth-child(3) > tbody > tr > td:nth-child(3) > table > tbody > tr:nth-child(4) > td')[0] | |
.get_text() | |
.replace('\n', '')) | |
account_status = re.sub(' +', ' ', account_status) | |
notification = Notify.Notification.new("PeopleNet Account Check", account_status, 'dialog-information') | |
notification.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Version for cron and systemd timers | |
from bs4 import BeautifulSoup | |
from pydbus import SessionBus | |
import requests | |
import re | |
import os | |
os.environ['DBUS_SESSION_BUS_ADDRESS'] = 'unix:path=/run/user/1000/bus' | |
os.environ['DISPLAY'] = ':0' | |
params = {'X_Username': 'your_username', 'X_Password': 'your_password'} | |
bus = SessionBus() | |
notifications = bus.get('.Notifications') | |
r = requests.post('http://my.people.net.ua/TSU/WWW/ACCOUNT_INFO/', data=params) | |
b = BeautifulSoup(r.content, 'html5lib') | |
account_status = (b.select('body > table:nth-child(3) > tbody > tr > td:nth-child(3) > table > tbody > tr:nth-child(4) > td')[0] | |
.get_text() | |
.replace('\n', '')) | |
account_status = re.sub(' +', ' ', account_status) | |
notifications.Notify('PeopleNet Account', 0, 'dialog-information', | |
"PeopleNet Account Status", account_status, [], {}, 5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment