Yes, you can do it through python.
It’s really simple in my example we will gonna use this repository  https://github.com/Dinnerbone/mcstatus from GitHub.

About 99% of the stuff you want to write is already in the internet.

If you don’t have python installed go to https://www.python.org

Then when its installed type in terminal:
python -m pip install mcstatus

If it’s installed you can use my script to check your server status. Just change some of the variables to your one.

To download the script simply click the link.