Browse Source

Allowed any digits in train number (ex: IRN 01641)

python3
Dan Cojocaru 3 years ago
parent
commit
e4943b1f6e
Signed by: kbruen
GPG Key ID: 818A889458EDC937
  1. 2
      scraper/scrape_train.py
  2. 4
      server/server/v2/v2.py

2
scraper/scrape_train.py

@ -35,7 +35,7 @@ STATION_DEPARR_STATUS_REGEX = re.compile(r'^(?:(la timp)|(?:((?:\+|-)[0-9]+) min
# endregion # endregion
def scrape(train_no: int, use_yesterday=False, date_override=None): def scrape(train_no: str, use_yesterday=False, date_override=None):
# Start scrapping session # Start scrapping session
s = requests.Session() s = requests.Session()

4
server/server/v2/v2.py

@ -38,8 +38,8 @@ train_data_cache = {}
def get_train_info_schema(): def get_train_info_schema():
return jsonify(TRAIN_INFO_SCHEMA['v2']) return jsonify(TRAIN_INFO_SCHEMA['v2'])
@bp.route('/train/<int:train_no>') @bp.route('/train/<train_no>')
def get_train_info(train_no: int): def get_train_info(train_no: str):
use_yesterday = check_yes_no(request.args.get('use_yesterday', ''), default=False) use_yesterday = check_yes_no(request.args.get('use_yesterday', ''), default=False)
@filtered_data @filtered_data
def get_data(): def get_data():

Loading…
Cancel
Save