利用Python将短链接还原

  • 所需模块:requests
  • 测试版本:3.7.1
  • 实现代码:
import requests

def geturl(url):
		res = requests.head(url)
		url = res.headers.get('location')
		return url
  • 测试:
import requests
def geturl(url):
    res = requests.head(url)
    url = res.headers.get('location')
    return url
print(geturl('http://url.cn/5NdpZhY'))
'''输出
https://i.y.qq.com/v8/playsong.html?platform=11&appshare=android_qq&appversion=8090805&hosteuin=owvPNeEA7w4z7c**&songmid=004ZyE0M1JpB7U&type=0&appsongtype=1&_wv=1
'''
发布了10 篇原创文章 · 获赞 10 · 访问量 3923

猜你喜欢

转载自blog.csdn.net/FairyTale__/article/details/89046413