首页 > 解决方案 > python中的URL缩短器

问题描述

对于 URL Shortening,我在这里使用了Adfly. 但我收到类型错误!

from pyshorteners import Shortener

url = "https://www.geeksforgeeks.org/url-shorteners-and-its-api-in-python-set-1/?ref=lbp"
ShortenedURL = Shortener('Adfly' , uid ='24352319' , key='07eb7bf58efa292d99437daddea9496b' , type = 'int')
print("Short URL is {}".format(ShortenedURL.short(url)))

错误 :

TypeError                                 Traceback (most recent call last)
<ipython-input-45-fb2e845d42a4> in <module>
      8 
      9 url = "https://www.geeksforgeeks.org/url-shorteners-and-its-api-in-python-set-1/?ref=lbp"
---> 10 ShortenedURL = Shortener('Adfly' , uid ='24352319' , key='07eb7bf58efa292d99437daddea9496b' , type = 'int' )
     11 print("Short URL is {}".format(ShortenedURL.short(url)))
     12 get_ipython().run_line_magic('pinfo', 'Shortener')

TypeError: __init__() takes 1 positional argument but 2 were given


我无法区分错误。请帮我。

标签: python-3.xurl-shortener

解决方案


推荐阅读