How I learned to stop worry and leverage python to become an influencer

reuglewicz jean-edouard
9 min readApr 16, 2023

Intro

Around a year ago, I stumbled on this video. At the same time, I was starting my journey in Google Cloud Console and was moving to Paris to join a company called SFEIR. I saw this as an opportunity to both get free food and get some experience with Google Cloud Platform.
Therefore I decided to create an Instagram bot.

My Strategy

Getting the content

I decided to re-implement the same strategy as in the video.
First finding a few accounts about Paris and siphoning their pictures.
Then filtering on the location but also on description. Sometimes the could have promotional or more personnal content that I did not want to relay
Then, I also extracted the 30 most used tags in their parisian pictures.
Finally, it was all stored in the cloud.
I also generated a google sheet containing 100 quotes about Paris that I would randomly use as descriptions.
Then, I extracted the followers of those accounts and would send them follow request before unfollowing them two days later, growing my audience and targeting people interested in then type of content I was providing.

Posting

Every morning, a picture will be randomly selected from the bucket, then, select a random quote from the quotes, adding the 30 tags, tagging the owner of the picture (otherwise that would just be disloyal to their work) and posting.

Growing the audience

Having great quality content is great, but if there is nobody to see it, you may as well be shouting in the void. So I did some tinkering and after some trial and error and being blocked by Instagram a few times, sending following request at different moments of the day and follow/unfollow around 150 (so 75 follow and 75 unfollow) to be the sweet spots.
The follow and unfollow two days later can seem rude, but that’s what you have to do to keep and audience with a good level of engagement and a good follower/following ratio. Moreover, as long as they receive quality they like, I believe it to be a win-win situation.

My Stack

The main target was to get some experience with google cloud in a funny project leveraging the 300 euros and 3 months of free services that google offers.
This gave me the opportunity to tinker with cloud functions, big query and cloud storage.

  • Big query is a cloud-based, fully-managed, serverless data warehouse that enables scalable, SQL-like querying of massive datasets. It allows users to query large, complex datasets quickly and easily, using SQL-like queries and integrating with other Google Cloud products for visualization and machine learning. With BigQuery, users can access data stored in various formats, including CSV, JSON, and Avro, and query it using a familiar SQL-like syntax. BigQuery is highly scalable and can process terabytes of data in seconds, making it a powerful tool for data analysis and business intelligence.
    I thought about using cloud sql first as it was more fit for the kind of transactional needs of this application. However, it was much more expensive than using big query so I made this choice.
  • Cloud storage is a cloud-based object storage service offered by Google. It allows users to store and access data on Google’s infrastructure, providing highly scalable, reliable, and secure storage for a wide variety of data types. Google Cloud Storage offers several different storage classes, including Nearline, Coldline, and Archive, which cater to different data storage needs and budgets. It also offers integration with other Google Cloud products, such as Google BigQuery for data analysis and Google Compute Engine for running computing workloads. With Google Cloud Storage, users can store, manage, and access their data from anywhere in the world, making it a powerful tool for data storage and management.
    I used it first to upload the csv data that I then loaded into big query along with the photos that were extracted from Instagram
  • Cloud functions is a serverless, event-driven computing platform offered by Google Cloud. It allows users to write and deploy small, single-purpose functions that respond to events and automatically run and scale, without the need to manage infrastructure. Google Cloud Functions provides a highly scalable and cost-effective way to build and deploy serverless applications and microservices. It integrates seamlessly with other Google Cloud products and offers support for multiple programming languages, including Node.js, Python, and Go. With Google Cloud Functions, developers can focus on writing code, rather than worrying about infrastructure, making it a powerful tool for building modern, cloud-native applications.
    This is a good way to execute some code on demand in a cheap and efficient way.
  • I thought about using compute engine, a cloud-based virtual machine service offered by Google Cloud. It allows users to run and manage virtual machines, or compute instances, on Google’s infrastructure, providing scalable, high-performance computing resources. With Compute Engine, users can create and configure virtual machines with a variety of operating systems, CPUs, and memory options, and access them over the internet. Compute Engine also offers a range of other features, such as load balancing, auto-scaling, and integration with other Google Cloud products, making it a powerful and flexible tool for running a wide variety of computing workloads.
    But it was both expensive but also not flexible enough for my tastes, especially given that I would need to use selenium and some graphic interfaces manipulations that ware not cheap in GCP.
    In consequence I chose to work locally, using python and selenium for scrapping.

The story

The first step was to scrape datas from 10 instagram accounts that I isolated to be about paris and having a lot of high qualities photos about Paris.
I scraped the location, profile name, description and the tags.
Then, I also scraped their followers. I’ll be targeting them later by sending them follow requests.
But having scrapped their pictures is not enough. Those accounts are personal accounts, so it could be that some of the pictures are not in Paris or are sponsored contents that I don’t want to relay.
So, I first added a filter on the location and filtered out everything that was not located in Paris and around Paris. Then, using a bit of regex, I removed content based on the descriptions if they were not Paris landscape oriented.
Finally, to be sure that I did not have any duplicates in my pictures, as maybe some of those accounts were actually relaying pictures just like me. I created some hashes of the images and used them to de-duplicate the pictures.
Finally, I had a table of unique and high quality images that I could use to post daily pictures.

Loading images and datas from csv and cloud storage
data structure of the project

The next step was to optimize the tags. Here I went for an easy road. and looked for the tags in the descriptions.
I counted each of them and picked the 30 most common ones as tags. For paris, they are as follow:

Finally, I created a list of 100 quotes about Paris in google sheet from different actors, authors, artists… Just like I loaded the data for the pictures, I loaded them into big query

Loading quotes about Paris from google sheet

I was now ready to get create an audience. I had the content and I had the targets.
I posted once a day, first manually, using some command line interfaces calling my scripts and doing some trials and errors to which is the optimal number of follow and unfollow per day to not get caught by Instagram for strange behavior

posting a picture and quotes to instagram
follow un-follow mechanism

Then I automated the whole thing using python and some cron jobs.
The photos, once posted would see their status in the insta_paris_table updated from false to true to avoid double posting (big query is not optimized for updates but with this limited amount per day it was not an issue). And the followed accounts would be added from raw_followers_table to followed_accounts.
Every day based on the follow date, the script would unfollow the people that were followed two days previously.

It all worked great for some time and the growth would be constant. At some point, some part of the automation were broken due to some changes in Instagram front-end and then came back up as operational. However, now, a lot of functionalities do not work anymore as Instagram drastically changed its front-end and I did not make time to do a lot of modifications to follow them. This being said, it is still operational enough to save a lot of time and still grow the audience.

ROI

Here are a few data points that were provided by the Instagram for business application (data that you can get once eligible for monetization, which I am making me actually an influencer). As they don’t cover the full lifespan of the account, the data may not be entirely representative, but they are a good estimation of the demographic of my audience

Global distribution of men vs women
Global distribution by age bucket
Global distribution per age bucket per men
Global distribution per age bucket per women
Global distribution per country

Most of my audience seems to actually be from France and the US. It also seems that there is a slight bias toward women between 35 and 55.

December was a very good month, maybe because the account was starting to get some traction, I remember some of the new suscribers were starting to be ‘organic’ ones.
Moreover, it seems that thursday, saturday and sunday are the best days for my targeted audience.

Next Steps

I am currently still using the bot and still posting even if the latest updates in the Instagram frontend made quite a few of my automation scripts redundant. For instance the posting of pictures does not work anymore and the follow/unfollow process is also not as efficient as it used to be. It is still working but it sometimes re-follow persons I unfollowed.
I took a bit of time to fix those bugs, but I did not find a fully functioning new solution yet.
This being said, it is still working great and the audience is still growing even if it is not as efficient as it used to be.
This also enabled me to get a professional account on Instagram, thus making me indeed an influencer so mission accomplished.
I am now trying to leverage my audience to sell my own products like NFTs and canvas poster. But this is a story for later.

--

--

reuglewicz jean-edouard

Engineer passionate about technology, data processing and AI at large, doing my best to help in the machine uprising https://elbichon.github.io/