Over the winter holidays I picked up a new hobby. I have heard much about Python over the years however it has recently gained prominence for it’s use in SEO recently. I will add that by no means am I a coder, although I do have some coding experience, namely PHP and some JavaScript for many projects over the years.

I have come across many articles on Twitter of late in which Python has been used to augment technical SEO processes, particularly with larger sites.

So what actually kickstarted this journey into the world of Python? I received an e-mail newsletter from Codecademy before the holidays that recommended the book Automate the Boring Stuff with Python, 2nd Edition: Practical Programming for Beginners so I picked up a copy.

My home office ;)

I setup an Amazon AWS ec2 instance to test out Python. My first move was to setup a “Django Bitnami” instance but then figured there had to be an easier (more visual way.) After some research online I later discovered that the easiest way would be a Windows Server instance would be a better route.

I came across this Python for SEO resource from JC Chouinard – Python for SEO: Complete Guide

Yes, I do love SEO.

The above resource recommend starting out by installing Anaconda which is a Python toolkit which includes various modules as well as Spyder browser.

There were several scripts available, the first that I used connected to Google Search Console using OAuth API. It exported a list of data related to organic searches including search queries and relevant metrics including date, page, query, clicks, CTR, impressions, and avg. position segmented by month.

Python script connecting to GSC and exporting data to CSV

The next script I worked with scraped a pre-loaded list of URLs via CSV and scraped for common keywords and returned the top 10 common keywords along with instances of each keyword. A very simple but useful script which most certainly got the wheels turning.

My next foray into Python will be to build machine learning models using TensorFlow, PyTorch, pandas and more. Very excited for the possibilities for taking our SEO campaigns to the next level.