Home > front end >  I am trying to make an URL shortener and I am facing this problem
I am trying to make an URL shortener and I am facing this problem

Time:12-25

This is the python code:

import pyshorteners as p
    
link=input("Enter the link: ")
shortner=p.tinyurl.short(link)
x=shortner.tinyurl.short(link)

print(x)

This is the error: module 'pyshorteners' has no attribute 'tinyurl'

CodePudding user response:

Replace

shortner=p.tinyurl.short(link)

with

shortner=p.Shortener()

Taken from the example here: https://pyshorteners.readthedocs.io/en/latest/

CodePudding user response:

That's because pyshorteners doesn't have an attribute tinyurl Try using the example from the documentation (https://pyshorteners.readthedocs.io/en/latest/apis.html#tinyurl-com) instead

import pyshorteners
s = pyshorteners.Shortener()
s.tinyurl.short('http://www.google.com')
  • Related