[Guide] Simple interlinking solution for your website using Link Whisper + python

  • Thread starter Thread starter Deleted member 832639
  • Start date Start date
D

Deleted member 832639

Guest
I've started learning QA automation recently. I also have a couple of AI websites, and there's an urgent question for many of us: how to automate internal linking.
I've been using Linkwhisper for a while, and I like it. However, as I accumulated more articles, it became quite challenging to click all the buttons manually. Moreover, it's not just about clicking; I have to wait for the page to load for quite a while.
That's why I decided to come up with a quick solution for myself and share it with you, guys.

So, here's what we need:
a Link Whisper (I'm using a version 2.1.6 pro) and Python with the Selenium module.

What are we doing?

In Linkwhisper, you can assign outgoing links or incoming ones. We won't be able to control outgoing links too much, but we want at least a couple of links on every article (I decided on 5, but you can adjust it as you want), yet not too many. Whisper offers all possible options.

So, we go to the plugin settings: Link Whisper Settings - general settings - scroll all the way down - Max Number of Suggestions to Display, set it to 5.
Now you'll only get 5 suggestions, not all of them.

1.jpg

Check your posts list; it should look like mine - 20 posts per page and the link stats block.

3.jpg

Now, install Python, the Selenium module, copy the script like mine, change the site name, login, and password, input your data, and enjoy.
The script will go through 100 pages (you can set more if you want), 20 articles per page, and add 5 links each. It will take a lot of time, but it works.
I also want to mention that the script skips posts where there are already 5 links.

Code:
import time
from selenium import webdriver
driver = webdriver.Chrome()
from selenium.webdriver.common.by import By
driver.maximize_window()
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver.implicitly_wait(5)

#website admin url
driver.get("https://yourwebsite.com/wp-admin") 
time.sleep(2)

#login and password
name = driver.find_element(By.ID, "user_login")
name.send_keys("login")
password = driver.find_element(By.ID, "user_pass")
password.send_keys("password") 
btn = driver.find_element(By.ID, "wp-submit")
btn.click()
time.sleep(1)


for i in range(1,100):
    driver.get(f"https://yourwebsite.com/wp-admin/edit.php?paged={i}") #website
    time.sleep(2)
    for n in range(1,21):
        textel = driver.find_element(By.XPATH, f"//tbody/tr[{n}]/td[17]/span/span/a/span[2]")
        text = textel.text
        if text == "0":
            linkbtn = driver.find_element(By.XPATH, f"//tbody/tr[{n}]/td[17]/span/span/a")
            link = linkbtn.get_attribute("href")
            driver.get(link)
            add = WebDriverWait(driver, 120).until(EC.presence_of_element_located((By.ID, "select_all")))
            add.click()
            btn = driver.find_element(By.ID, "inbound_suggestions_button")
            btn.click()
            WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.CLASS_NAME, "swal-button--confirm")))
            driver.get(f"https://yourwebsite.com/wp-admin/edit.php?paged={i}") #website
            time.sleep(2)
        else:
            print("skip")

time.sleep(10)
print("END")

Thanks to everyone, and good luck with your cool earnings.
 
Actionable SEO share.
Thanks for the knowledge op.
 
Quick update. The new script goes only for published articles and does not crash if there are no options for links on the page (I had this several times).
I also tried it on another site and found that if the structure of the posts page is slightly different, then you just need to correct the table number:

Code:
textel = driver.find_element(By.XPATH, f"//tbody/tr[{n}]/td[14]/span/span/a/span[2]")

Check and check this td[14] to 15, 17 or whatever. Just open browser console F12, press find - ctrl+f and paste //tbody/tr[{n}]/td[14]/span/span/a/span[2], then you will see what link to press.

Code:
driver.get("https://www.site.com/wp-admin")
time.sleep(2)

name = driver.find_element(By.ID, "user_login")
name.send_keys("...")
password = driver.find_element(By.ID, "user_pass")
password.send_keys("...")
btn = driver.find_element(By.ID, "wp-submit")
btn.click()
time.sleep(1)


for i in range(1,100):
    driver.get(f"https://www.site.com/wp-admin/edit.php?post_status=publish&post_type=post&paged={i}")
    time.sleep(2)
    print(f"page {i}")
    for n in range(1,21):
        textel = driver.find_element(By.XPATH, f"//tbody/tr[{n}]/td[14]/span/span/a/span[2]")
        text = textel.text
        if text == "0":
            linkbtn = driver.find_element(By.XPATH, f"//tbody/tr[{n}]/td[14]/span/span/a")
            link = linkbtn.get_attribute("href")
            driver.get(link)
            add = WebDriverWait(driver, 120).until(EC.presence_of_element_located((By.CLASS_NAME, "wpil-export-suggestions")))
            isPresent = driver.find_elements(By.ID, "select_all")
            if len(isPresent) > 0:
                    add = WebDriverWait(driver, 120).until(EC.presence_of_element_located((By.ID, "select_all")))
                    add.click()
                    btn = driver.find_element(By.ID, "inbound_suggestions_button")
                    btn.click()
                    WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.CLASS_NAME, "swal-button--confirm")))
            else:
                print("no suggestions")
            driver.get(f"https://www.site.com/wp-admin/edit.php?post_status=publish&post_type=post&paged={i}")
            time.sleep(2)
        else:
            print("skip")

time.sleep(10)
print("END")

Nice share , but do we install python
Yes we need to install python and selenium module
 
This is excellent, thanks. Is there a free version of Link Whisper?
 
Thanks for this, I just got Link Whisper and this was the missing part.
 
View attachment 277280

Check your posts list; it should look like mine - 20 posts per page and the link stats block.

View attachment 277287
Hello. Idk why, maybe it's about plugin version but im missing options You have. My panel looks like:

1706568217388.png
There is no fourth symbol

In Screen Options there is only "Link Stats" to mark. Outgoing internal links and received internal links options doesn't appear there. Cuz of that script doesn't work for me. Do You know any solution for that?
 
Back
Top