This Python script scrapes and parses train schedules for all stations of the Yekaterinburg Metro system from the official website (https://metro-ektb.ru). It extracts timetable information for both weekdays and weekends, in both directions (toward "Botanicheskaya" and "Prospekt Kosmonavtov" stations).
- Scrapes schedule data for all metro stations
- Outputs clean, structured JSON data
- Formats times as "HH:MM" strings
- Python 3.6+
- Required packages:
- requests
- beautifulsoup4
- lxml (or another HTML parser for BeautifulSoup)
Install dependencies with:
pip install -r requirements.txt- Run the script:
python parser.pyThe script generates a JSON file with the following structure:
{
"stations": {
"1": {
"name": "Название первой станции",
"schedule": {
"weekday": {
"to_last": ["08:00", "08:15", "08:30"]
},
"weekend": {
"to_last": ["08:05", "08:20", "08:35"]
}
}
},
"2": {
"name": "Название второй станции",
"schedule": {
"weekday": {
"to_first": ["08:10", "08:25", "08:40"],
"to_last": ["08:12", "08:27", "08:42"]
},
"weekend": {
"to_first": ["08:15", "08:30", "08:45"],
"to_last": ["08:17", "08:32", "08:47"]
}
}
},
// ... станции 3-8 ...
"9": {
"name": "Название последней станции",
"schedule": {
"weekday": {
"to_first": ["08:20", "08:35", "08:50"]
},
"weekend": {
"to_first": ["08:25", "08:40", "08:55"]
}
}
}
},
"station_order": [1, 2, 3, 4, 5, 6, 7, 8, 9]
}This project is open-source and available for free use.