Recently I came up with the idea to create a Notifier application for codechef contests. During contests, after I solve some problem I use to see how other people in my group doing.. so I thought instead of checking everytime why not create an python app which would notify me for every new submissions done by my friends. Without any second thought i started working on the app.
Here's my project directory looks like.
The first thing to do was to get the data from the codechef website dynamically.
For that python has a library called "requests". Additionally to parse the HTML code in the data i used another library called "beautifulsoup4".
But i found that the module "requests" get the data from the webpage without letting the javascript content load. This is the big issue since the submissions on codechef are updated by javascript code.
So, next I used "chrome-driver" from library "selenium". Basically what it does is that it load the webpage first letting javascript load and then extract the data. so problem solved.
[this part of the code uses the chrome-driver, gets the data from website, calls check ()function which returns the last submission, the if last submission doesnt match with the stored one, then call the function notify(), and write the new data to json file.. all this happen for all the users in the database]
[functions: speakUp(), check(), and notify()]
Now I have the data and I parse it using "beautifulsoup". The next question is how do i notify this data on my PC. This can be done using "notify2" library, this has even the option to set the logo for the notification.
I made a json file containing name, username and the last_submission of all the people in my group at codechef. Now I can check for each username what its last submission is . If the last submissions doesnt match with the stored last_submission then I just notify it on the pc and save the newest submisson to the json file.
I made an additional function called "speackUp" which will speak up the notification message to me, (imagine my pc talking to me) , cool right !
I made the main function in the end and set all the things. I even made this project as a package, followed official packaging docs in python3.x. I will add this to my github soon.
[used libraries]
Here the demo video: [see that push notification... that's my app]
[github link : https://github.com/alpeshjamgade/codechef-notifier]
Here's my project directory looks like.
The first thing to do was to get the data from the codechef website dynamically.
For that python has a library called "requests". Additionally to parse the HTML code in the data i used another library called "beautifulsoup4".
But i found that the module "requests" get the data from the webpage without letting the javascript content load. This is the big issue since the submissions on codechef are updated by javascript code.
So, next I used "chrome-driver" from library "selenium". Basically what it does is that it load the webpage first letting javascript load and then extract the data. so problem solved.
[functions: speakUp(), check(), and notify()]
Now I have the data and I parse it using "beautifulsoup". The next question is how do i notify this data on my PC. This can be done using "notify2" library, this has even the option to set the logo for the notification.
I made a json file containing name, username and the last_submission of all the people in my group at codechef. Now I can check for each username what its last submission is . If the last submissions doesnt match with the stored last_submission then I just notify it on the pc and save the newest submisson to the json file.
I made an additional function called "speackUp" which will speak up the notification message to me, (imagine my pc talking to me) , cool right !
I made the main function in the end and set all the things. I even made this project as a package, followed official packaging docs in python3.x. I will add this to my github soon.
[used libraries]
Here the demo video: [see that push notification... that's my app]
No comments:
Post a Comment