How to automate link building with Python

When it comes to SEO we have different branches in which one can specialize. On the one hand, there is the technical SEO, more focused on the SEO On Page part and, on the other hand, the SEO Linkbuilding profile, focused on increasing the authority of the website externally, which is known as SEO Off Page.

Within SEO Off Page we can follow 3 different paths:

  1. Generate quality content that adds value to the end user and that, in this way, we get them to link us from different relevant websites in our field and semantically related to our website. These are the links that Google wants us to obtain for our website, which it considers to be natural links.
  2. Define a Linkbuilding strategy to get those links in a less natural way by registering in forums, social profiles, 2.0 blogs, Wikis, etc.
  3. Buy the links in themed newspapers or blogs, which we know as sponsored reviews or posts, totally prohibited in the Google Webmaster guidelines.

Once we have seen the 3 main ways to get links for our linkbulding strategy, in this article we will focus on the second option defined previously.

When you have to register on different platforms to create profiles, it can become very monotonous to do it several times on the same website for different projects. That is why, thanks to Python, we can automate the records by simulating the interaction of a user with the browser. This can save us a lot of time, and in the end, time is money.

That said, let’s get down to business. In order to execute the Python script that automates the records, we will need different resources that I attach below:

In these resources you basically have, on the one hand, all the Selenium documentation so that you can review all the calls that the Selenium API supports and, on the other, the drivers for Firefox and Chrome to be able to run browsers and simulate user actions in the registry on the different platforms.

The first thing we have to do is import the selenium libraries to be able to use the webdriver:

import time 

from selenium import webdriver

The next step will be to identify the different elements with which we want to simulate user interaction in the HTML code of the page:






GO_BUTTON_DROPMARK = '/html/body/section/div/div/form/input[5]'

Once we have collected this information, the next step will be to provide the registration data to the script so that it can fill out the form. In that case I have added the data directly, although it could be requested by keyboard from the user or loaded from a DB directly.

#Input data 

email = "" 

password = "juanadormideras2021" 

username = "juanadormideras" 

name = "Juan" 

lastname = "Adormideras"

With all this information, we can only run the Selenium webdriver so that it begins with the user’s registration, simulating the user’s interaction through the browser.

#Selenium driver 

print("+Registration Dropmark") 


driver = webdriver.Firefox('/Users/rafavillaplana/AppData/Local/Programs/Microsoft VS Code/bin') 





element = driver.find_element_by_name(FIELD_NAME_DROPMARK) 

element.send_keys(name +' '+ lastname) 


element = driver.find_element_by_name(FIELD_EMAIL_DROPMARK) 



element = driver.find_element_by_name(FIELD_USERNAME_DROPMARK) 



element = driver.find_element_by_name(FIELD_PASSWORD_DROPMARK) 



element = driver.find_element_by_xpath(GO_BUTTON_DROPMARK) 





The first thing we do in the code is open the website registration URL using the Firefox browser. Once the Web is open, we wait 5 seconds for it to finish loading and simulate a user waiting time.

Next, by calling find_element_by_name what we do is search in the HTML code for the element whose name matches that field and we send the value that we have stored in the variables name + lastname. We repeat this process for the rest of the form fields.

At the end, when we have already filled out the entire form, we proceed to click on the registration button. To locate this element in the code we have used the Selenium API call find_element_by_xpath which allows us to find the element in the code using XPath paths.

And with all this, we would already have the registration ready on the platform in a fully automated way. So we proceed to close the browser with the closecall.

With this simple example we can see the power that Selenium achieves with Python. It allows us to automate any action that the user has to perform through the browser. For this reason, websites use Captchas to avoid automated registrations like the one we have shown you.

But for this there is also a solution, since there are services such as DeathbyCaptcha or 2Captcha that provide APIs to be able to solve most of the captchas on the market. Here we leave you the resources in case you want to investigate a little, since this would give for another article:

With all this I say goodbye, I hope you liked the article and see you in the next chapter on linkbuilding automation with Python.

Rafa Villaplana

SEO Manager

Apasionado del SEO y Marketing Online. Lo único que cae del cielo es la lluvia.

Wanna talk?
Only PDF, Word and OpenOffice files. Size: 2MB max.

Premium Leads S. L. will only use your data to answer your request and they will never be given to third parties. To exercise your rights, check our privacy policy.