Gab Auto-like with Pyautogui, and OpenCV 🐍

Twitter’s attempt to shut down QAnon conspiracy theorists has led to a spike in membership at Gab. In an attempt to capitalize on this, I’ve coded an auto-like Python bot with the long-term purpose of increasing traffic to my blog, Passivebot.

What is required?
  1. Python 3
  2. ChromeDriver – if you haven’t added the location of your web driver to PATH and are having trouble, refer to:  Stack Overflow
  3. Selenium, pyautogui and OpenCV libraries

Built-in process

Gabber is programmed to perform specific tasks in a certain order. I’ll be breaking down that order along with the code.

Skip to full code source: Github

Initiating a Chrome instance:
A new instance of Chrome is opened using Selenium. This will be a guest profile by default meaning that you need to ensure your account login credentials are updated in the ACCOUNTS dictionary.


Accessing Gab


The GabLogin() function will open Gab, input the login credentials and attempt to sign-in. There is a fail-safe that causes the function to call itself if for some reason it’s not able to login to your profile and extract the account name, number of Gabs, number following, and number of followers. These values will be displayed in the terminal.


Liking Posts


After displaying the account variables, Selenium is used to fetch a URL and the likeFunction() is automatically called.

Figuring out how to execute this step took a couple of tries. The first method I attempted was the find_element_by() function. I ran into an issue with all the buttons on the timeline being named the same. I then tried to access the like button using the keyboard library but was unsuccessful because of the buttons not getting highlighted when you send TAB and there also being an inconsistency between the number of times TAB was needing to be sent to get to the next like-button. Finally I tried using the pyautogui library to find an image on the screen by matching it to a PNG file.




Once the image on the screen matches with the PNG file above a specific confidence interval, the function clicks that particular region. Since the PNG file is literally a screenshot of the Gab like-button, every time Gabber detects a like-button on screen, it clicks it proceeds to the next line of code. 


Using try/except/else, I set-up 3 total scenarios for the bot.

  1. like-button is present when the timeline first loads. If that’s the case, then the function will automatically click the button and call itself again.
  2. like-button isn’t present on the screen when the timeline first loads. If that’s the case, the function will then press Page Down, wait momentarily and then scan the screen for like-button.
  3. like-button isn’t present on the screen when the timeline first loads or when Page Down is pressed. In that case Page Down will be pressed again, the function will scan the screen and call itself again.

These three scenarios have been sufficient to keep the Auto-Like bot in an infinite loop until the browser is exited out of. 


As I mentioned in the beginning of this blog, the purpose of the bot is to eventually increase traffic to my website. I started the Gab account yesterday and have gotten 55 followers since then. To increase the hourly productivity of the bot, the next function I’ll be adding to it will be to follow profiles and then to unfollow profiles. I’ll be updating the source code on Github within a few days to reflect the new functions. 

If you have any questions, feel free to reach out on Passivebot or Github

Published by Passivebot

Earn gift-cards & Bitcoin passively

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: