Skip to content
Advertisement

Create hyperlink and give it an appealing name in Python

I am trying to rename my hyperlink to place in a pdf file. Thus, I do not want to give to the user a massive long link. Let’s say my link is like:

https://www.google.com/search?q=images+of+dogs&rlz=1C1OKWM_esES969ES969&sxsrf=AOaemvJFDb3FKdXO1Yqb3A1BdjWNfw0Edg:1632237403618&tbm=isch&source=iu&ictx=1&fir=D5X9VdSPli-xYM%252CHUMB4Zy1hHwFaM%252C_&vet=1&usg=AI4_-kShuarwW69ikZrP2YUHRVOpRHKKfQ&sa=X&ved=2ahUKEwiPs4aVrpDzAhUR1RoKHQiNAZIQ9QF6BAgPEAE&biw=2133&bih=1013&dpr=0.9#imgrc=D5X9VdSPli-xYM

And I want it to appear in the pdf like: “Link to picture”

My code: 
texto_body=f"Hi,<br> <br> This is a test with a link {link} <br> <br> Thanks,"

  body=f"""
          <html>
              <body>
                <p style="color:black;"> {texto_body}</p>
                <img src="cid:image1" alt="Logo" style="width:90px;height:90px;"><br>
              </body>
          </html>
"""

Advertisement

Answer

Solved. I found that <a href="where/you/want/the/link/to/go">text of the link</a> is the way to set up hyperlinks with a given name

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement