Author: Adam Pioterek <adam.pioterek@protonmail.ch>
don’t continue if db exists
research/scraper.py | 6 +++++-
diff --git a/research/scraper.py b/research/scraper.py index e2310f633c82ead3cde67e558155a3e9bb0626c8..96b855fb4275f76a18daad2486598937c3391e31 100755 --- a/research/scraper.py +++ b/research/scraper.py @@ -9,6 +9,7 @@ """ import json import hashlib +import os import re import sqlite3 import sys @@ -86,7 +87,7 @@ """ session = requests.session() index = session.post('https://www.ztm.poznan.pl/goeuropa-api/stop-info/{}/{}'. - format(stop_id, line_id), data={'directionId': direction_id}, verify='caert.pem') + format(stop_id, line_id), data={'directionId': direction_id}, verify='bundle.pem') soup = BeautifulSoup(index.text, 'html.parser') legends = {} for row in soup.find(attrs={'class': re.compile(r'.*\blegend-box\b.*')}).findAll('li'): @@ -129,6 +130,9 @@ def main(): """ main function """ + if os.path.exists('timetable.db'): + return + print(time.time()) with sqlite3.connect('timetable.db') as connection: print('creating tables')