Files
bibreminder/bibcheck.py
Matthias Bilger defa866a56
All checks were successful
continuous-integration/drone/push Build is passing
log somethings
2019-09-25 06:30:25 +02:00

37 lines
1.3 KiB
Python

import bs4
import requests
import configparser
import urllib.parse
import mechanize
import pushover
import datetime
pushover.init('a5uja274ec5h46paanzjqy5zo1ym6y')
def main():
br = mechanize.Browser()
starturl = 'https://ssl.muenchen.de/aDISWeb/app?service=direct/0/Home/$DirectLink&sp=SOPAC'
response = br.open(starturl)
br.follow_link(text_regex=r"Anmelden")
br.select_form('Form0')
br['$Textfield'] = '400006306065'
br['$Textfield$0'] = '54zjxTHvIY'
response = br.submit()
br.follow_link(text_regex=r"Konto")
response = br.follow_link(text_regex=r"Ausleihe zeigen")
lentlist = bs4.BeautifulSoup(response.read(), 'html.parser')
table = lentlist.select('table[class="rTable_table"]')[0]
import urllib.request
urllib.request.urlopen("https://health.d1v3.de/ping/5185e698-ea0b-44e0-857e-8f52487dca5d")
for entry in table.tbody.select('tr'):
info = list(map(lambda x: str(x.text).strip(), entry.select('td')))
date = datetime.datetime.strptime(info[1], '%d.%m.%Y')
delta = date - datetime.datetime.now()
print(delta, info)
if delta.days <= 10 or delta.days == 20 or delta.days == 15:
pushover.Client('u5w9h8gc7hpzvr5a2kh2xh4m9zpidq').send_message('Bitte an {} denken, Abgabe {}'.format(info[3], info[1]), title="Erinnerung")
if __name__ == "__main__":
main()