Skip to content

mycart/dwz-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dwz-python

本代码库演示了通过 Python 调用百度短网址 API 的方法。

  • Token 是必须的鉴权参数。

常规用法

from dwz import Dwz

dwz = Dwz("token")

# 为多条长网址链接创建 1 年有效的短网址 (dwz.cn/xxx)
long_urls = ["https://www.baidu.com/1","https://www.baidu.com/2"]
results = dwz.create(long_urls, "1-year")
# 为单条长网址链接创建长期有效的短网址 (dwz.cn/xxx)
short_url = dwz.create_single("https://www.baidu.com/3", "long-term")

# 查询 'https://dwz.cn/shortPath' 对应的长网址链接
long_url = dwz.query("https://dwz.cn/shortPath")

# 删除短网址:'https://dwz.cn/shortPath'
dwz.delete("https://dwz.cn/shortPath")

定制域名用法

定制域名目前可通过 工单 申请购买

from dwz import Dwz

# 假设定制域名为 'custom.dwz.cn'
dwz = Dwz("token", "custom.dwz.cn")

# 为多条长网址链接创建 1 年有效的短网址 (custom.dwz.cn/xxx)
long_urls = ["https://www.baidu.com/1","https://www.baidu.com/2"]
results = dwz.create(long_urls, "1-year")
# 为单条长网址链接创建长期有效的短网址 (custom.dwz.cn/xxx)
short_url = dwz.create_single("https://www.baidu.com/3", "long-term")

# 查询 'https://custom.dwz.cn/shortPath' 对应的长网址链接
long_url = dwz.query("https://custom.dwz.cn/shortPath")

# 删除短网址 'https://custom.dwz.cn/shortPath'
dwz.delete("https://custom.dwz.cn/shortPath")

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%