Hey everyone, I hope you’re having a fantastic time wherever you are.
I have been fantasising about creating my own applications for a while now but have always felt overwhelmed when trying to learn web frameworks such as Flask or Django.
While they do seem extremely powerful, I always felt like I’m way over my head and need an extremely good understanding of these tools even if I want to create a very simple application.
Thankfully, a new way of creating web applications in Python has recently caught my eye and lo and behold, it has made it extremely easy to convert your Python scripts into an actual web application that you can share with your peers.
In this article, I want to share my own application that I made for technical SEO purposes. This application is a tool that allows you to retrieve the ranking position of multiple keywords for multiple domains. It’s entirely free to run and uses an external API which offers 100 SERP calls a month for free. Above that, you will have to pay a subscription but depending on your needs, it could be that 100 calls monthly will be plenty enough for you. Here is how the interface looks like when set up and working:
So without further ado, let’s jump into the code and how to run it on your own computer.
Requirements
The API that is going to power this application is provided by Serpstack. Serpstack presents themselves as a Real-Time and accurate Google Search Results API.
In order to retrieve the API key that you will need to have this interface working, just head over to this page and create an account.
They offer up to 100 monthly calls for free before asking you to upgrade to one of their premium plans which start at 29 USD/month for 5000 calls or 24 USD/month if billed annually. Whether that’s worth it or not is subjective but for following the ranks of a few keywords for a few websites, I found that 100 calls per month was enough for me.
I am also investigating creating the same tool that would be powered by the API from the fine folks at DataforSEO. The upside of their API is that it works with credits instead of with a subscription, meaning that you can buy 50 USD worth of credits and keep them for as long as you need. The downside though is that for the same amount of calls as Serpstack’s cheapest premium plan, DataforSEO would be extremely more expensive.
The second requirement to follow this article is to have Streamlit installed on your machine. If you don’t know about Streamlit, they’re one of the latest web framework for Python developers and is geared towards people with no front-end coding experience. They have been blowing up recently in the Technical SEO community and are definitely worth checking out if you’ve always wanted to create an actual application from your Python scripts.
To install Streamlit on your machine, simply use the command “pip install streamlit” in your terminal. Make sure that your version is at least 0.84 as the application I’m about to share with you uses features that have only been introduced from Streamlit 0.84 .
And that’s it, we can now jump onto the code.
How to check your keywords ranking with Python
At the heart of this whole application, we are going to use Serpstack’s API.
Before I share the entirety of the application with you, I do want to show you how this API works in its most bare bone use case.
Once you have your API key, you can run this code to see if your domain appears for any keyword of your choice in the first two pages of Google:
This code can easily be ran within a terminal or a Jupyter notebook.
In terms of customisation and for it to work, you are going to want to edit a few lines there:
In Line 1, replace the value of the variable with your own Serpstack API key.
In Line 4, you can choose whether you want to query the Desktop index, the Mobile index or even the Tablet index.
In Line 7, you can choose which Google domain you want to query such as google.com, google.de or else.
In Line 10, you need to choose which keyword you want to check the ranking of.
In Line 11, you need to choose which domain you want to look for the keyword previously chosen.
And that’s it. Once you have all of this set, you can run the whole script and it will print your result.
Now, this is all pretty and dandy but you might have come here for the actual rank tracker application that can query multiple keywords against multiple domains at once, so let’s jump into this part of the article now.
Run the Rank Tracker application on your computer
Once you have Streamlit installed and a Serpstack API key available, it is time to create the Python file where the application will be coded in. And without further ado, here is the undocumented and messy file that I created for you all:
Once you have saved this code in a file, we can finally run it.
Open your terminal from the folder where your file is located and input “streamlit run filename.py“. This should open a locally hosted instance of Streamlit with this blank interface:
The first thing we want to do in order to use the tool is input our Serpstack API key in the first text field.
After that, the rest of the interface follows the same principle as the sample code outlined earlier.
You can choose if you want to query the Google desktop or mobile index.
Then you can choose which Google Domain you want to test your keywords against. By default it’s going to be “google.com”.
Finally, you can enter the keyword(s) you wish to check the position for for which domain(s) by also putting the domain name(s) below.
Here is an example of me wanting to check where martechwithme.com and stackoverflow.com rank for the keywords “python photoshop,rank if google sheets,bitcoin price google sheets” :
Once you’re done filling all of the fields, you can press the Submit button to launch the sequence. Depending on the amount of keywords and domains you’ve picked, it might take a while but I also incorporated a progress bar so you can have an idea of how far the task is done from completion.
Finally, the result will be displayed like this on our screen where you will also be able to export the output as a CSV by right-clicking on the “Download CSV File” link and naming your saved file (Do not forget to add .csv at the end of your filename).
And that is all. As mentioned earlier in the article, this application is powered by Serpstack but I am looking at giving the user the choice of also using credentials from another SERP API provider named DataforSEO.
If you liked this project, please consider sharing it around with your peers so as to have as many people as possible appreciate this work. And if you want to see more of this, please consider joining my weekly newsletter using the form down below so you can be notified where I find other cool projects such as this one and follow the Marketig technology industry more closely.
If you have any questions about this project, feel free to reach out to me using the comments section down below or directly by email and I will try to get back to you as soon as I can.
16 Responses
sd7col
gpblu3
f3hfd2
7j7agz
d5oe48
538j60
on3s8x
f4tllu
z2ga3c
zn1a8f
8lfeu5
nun7wt
jhcse3
64v9tu
8k2jwy