0

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'

ScottMcC
  • 4,094
  • 1
  • 27
  • 35

3 Answers3

1

Replace

shortner=p.tinyurl.short(link)

with

shortner=p.Shortener()

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

ScottMcC
  • 4,094
  • 1
  • 27
  • 35
1

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')
SamBob
  • 849
  • 6
  • 17
0

you must use Shortener() from the pyshorteners. To solve this problem you can use the code below:

from pyshorteners import *

print(Shortener().tinyurl.short('http://www.google.com'))