'How to convert link to text by selenium using Python

I want to capture and get text from image. But it returns me a link. How can I convert it to text? This is my code.

import urllib

import img as img
import pyautogui
import pytesseract
from PIL import Image
from pytesseract import *
from select import select

from Tools.demo.markov import test
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By

test_driver = webdriver.Chrome()
test_driver.get('http://hamsterbabali.com/')
test_driver.implicitly_wait(4)

pytesseract.tesseract_cmd = "C:\\Program Files\\Tesseract-OCR\\tesseract.exe"

# Click the button "Register"
test_driver.find_element(By.XPATH, '/html/body/div[2]/div/div[2]/li[1]/a').click()

#get img source by using XPath
imgSource = test_driver.find_element(By.XPATH, '/html/body/div[14]/div[2]/div/center/div/div/div/form/div/table/tbody/tr[8]/td[2]/table/tbody/tr/td[2]/div/img')

# get the image
myImg = imgSource.get_attribute('src')
print(myImg)

What I got from the outputs: http://hamsterbabali.com/antispam.aspx?r=1652854214



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source