Introduction
I often use taxis to save time. I believe that you can pay for extra time to manage your tasks. I wrote an article about this topic in Russian. When I need more time, I can order a taxi and work on my laptop in the back seat instead of just staring out of a window on public transport.
Another important thing is that many taxi services increase prices during busy hours to reduce demand and ensure quality service.
So, I will describe in this article the fundamental concepts of my tool that can monitor and predict these price hikes.
Solution
So, I decided to solve this problem by researching the code of taxi routes page of Yandex.Maps. I wrote two scripts that you can find on my GitHub repository yandex_taxi_analyzer_v2:
Collecting data
In order to gather data, my script randomly requested to the Yandex Maps service to retrieve information about the cost of two trips: one from my office to home and the other from home to the office.
The script utilized various techniques to bypass the anti-bot protection, such as randomly switching between different proxy servers. The script obtained the list of proxy servers from the website https://free-proxy-list.net.
After processing and organizing the data, it was saved to an SQLite database. This allowed the visualization script to access the data and generate graphs based on the information obtained.
Visualizing collected data
For visualization, I used the excellent library matplotlib. My script regularly started, got data from the SQLite database, and saved several updated pictures on my server that I can see on my website.
I prefer graphs with context, so I plotted current taxi prices and statistics for this weekday: median, 25, and 75 percentile. It helped to predict taxi prices in the next few minutes or hours.
You can see one of the results below:
Conclusion
- It was funny and interesting. :)
- I created for myself a convenient service for taxi price monitoring.
- I found the optimal time for leaving the office and home if I wanted to use a taxi.