Skip to content

QiaosiLi/scrape_dynamic_table_from_website_with_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scraping dynamic table from the website with Python

Motivation:

I moved into a flat where I could always hear the rumble of trains, and then I realized that there is an underground railway just next to the flat. The rumbling sound is annoying and I wonder how often the trains pass by. Live timetables for specific train stations can be viewed on the ScotRail official website as shown below,

Screen Recording 2024-03-16 at 2 13 11 PM (1)

Methods:

In order to scrape the information of the live timetable, I wrote a Python code by using the Selenium library to open the website and scrape data every 10 min from 5:00 - 23:59, Monday to Sunday (code/scrape_timetable.py). Event plot (eventplot.py) and bar charts (code/barchat.py) are generated to visualize how many trains pass by per day.

Results:

eventplot plot_3-18-2024_Monday plot_3-19-2024_Tuesday plot_3-20-2024_Wednesday plot_3-21-2024_Thursday plot_3-22-2024_Friday plot_3-23-2024_Saturday plot_3-24-2024_Sunday

Conclusion:

  1. Using the Selenium library works well without being denied by the website.

  2. There are so many trains passing by every day, so DO NOT stay at home all day! Getting some peace during 21:21-21:45 (24 min) and 22:51-23:20 (29 min). Hope to move out soon...

About

Scraping dynamic table from the website with Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages