retrieves train statuses
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

from bs4 import BeautifulSoup
import requests, json
from pprint import pprint
class Scraper():
url = ''
def __init__(self):
def get_stations(self, filename):
_ret = []
with open(filename) as file:
return self.parse_stations(
return _ret
def parse_stations(self, stations):
_ret = []
for station in stations.split('\n'):
if len(station) > 0:
return _ret
def parse_station(self, station):
stat = station.split('|')
return {
'name': stat[0].strip(),
'code': stat[1].strip()
def find_stations(self, station_name, stations):
_ret = []
for station in stations:
if station_name.lower() in station['name'].lower():
return _ret
if __name__ == '__main__':
scraper = Scraper()
stations = scraper.get_stations('elenco_stazioni.txt')