Attendance Reporter
#day6 of #100daysofcode
I have explored a lot of things this time. Because I skipped documenting a couple of days. I know that’s not okay. But hey, that’s not going to happen again. There were certain things that interrupted it. Some college work and all that. But now I am back so from now I have decided to maintain my consistency. Let me tell you about the awesome things I have learned and explored. I mentioned in an earlier post that I was working on the Automatic attendance reporter. The idea is simple I want that a bot should text me my daily college attendance. In my college attendance is directly marked on UIMS(University Management System). If some teacher mark you absent but you were present over there then you have 2 days to report and get it right. But I think it is a repetitive and boring task to open the UIMS daily and checking attendance. I sometimes forget to check it for weeks. So I thought it would be nice to have an automatic system that will send me a message every day notifying whether my attendance is marked or not.
One solution was to use selenium. I had worked with selenium, it is a great library. I used it when I automated sending messages in WhatsApp. But it requires a web browser and one needs to set up proper web drivers. But I want to share it with my friends. I want that they can easily use it. So I explored further and found out that I can use the ‘requests’ library in Python to send HTTPS requests and can extract the information. I learned the ‘requests’ library. I got stuck at a point when I have to extract the attendance. As my university’s website is made in .NET and to extract the data I need to run the javascript file. Then I had some professional help :). My friend Ritiek has already worked on a similar problem and pushed his code on Github. I referenced his code but that code was not working at that time because our university website has been updated. So I contacted him and he solved the issue. He also taught me how to generate and write HTTPS requests. He told me about the mitmproxy tool that we can use to intercept the requests and can easily generate our requests.
The next step was to learn to make a Telegram Bot. It was fun and easy. Telegram is an open-source messaging app and its bot feature is very powerful. So I learned about the telegram API and how to use it in Python.
Creating a bot is very easy. I will briefly discuss how to approach it. First, open your telegram app or on the web. And search BotFather. This is a bot that will help you create a bot. After creating your bot you will need to copy your token because it is required to send requests and don’t share it. So steps are simple, first, extract information i.e attendance from college UIMS and then send the message using Telegram bot.
I have done till this step. The next phase is to deploy it. I can’t keep my laptop on all the time. I want that it should notify me around 6 O’ clock. I haven’t done the deploy part. That is for later on. I really like automating boring and repetitive work. Tomorrow I am going to explore something else because my University’s management system is not responding properly. I think too much traffic :). I will test my solution after a few days.
Keep learning and stay healthy. Once I will finish it then I will explain the code. And the whole process in detail.
Happy Learning!!!