diff --git a/parser.py b/parser.py index 4b9641b..cb4c702 100755 --- a/parser.py +++ b/parser.py @@ -1,29 +1,54 @@ #!/usr/bin/env python #-*- encoding: utf-8 +import sys import requests from html.parser import HTMLParser import caldav, icalendar -class GoogleSheetsParser(HTMLParser): +# Constants definition +URL = "https://docs.google.com/spreadsheets/u/0/d/e/2PACX-1vQ9yzFLr5mXbIZVK3ucdUZuScAbLoCyPqzHr-5V0aYeCFEz7LuidPdk_EnkkJT-zjemzQQHaKvpeXW2/pubhtml/sheet?headers=false&gid=1619638924" + + +class GoogleSheetsCalParser(HTMLParser): """ Definition of a Google Sheets parser providing a table with each cell and its position and size """ + def __init__(self): + self.inTable = False + self.row = 0 + self.column = 0 + self.__init__() + def handle_starttag(self, tag, attrs): + print(1) def handle_endtag(self, tag): + print(1) def handle_data(self, data): + print(1) # Getting the Google Sheet +try: + r = requests.get(URL) +except ConnectionError as e: + print(e) + sys.exit(1) +if r.status_code != 200: + print(f'Status Code {r.status_code}; could not continue.') + sys.exit(1) # Parsing the Sheet calParser = GoogleSheetsParser() +calParser.feed(r.text) # Transforming the cells into events + # Pushing events to caldav server +