microurl是一个python模块,用于创建minifiedurl
microurl的Python项目详细描述
用于url缩小的python库。
功能
- 谷歌
- 网址缩小符
- 二维码发生器
- 比特
- URL迷你者
安装
通过pip安装microurl
$ pip install microurl
或者,如果您想要github上当前的代码
git clone git://github.com/micropyramid/microurl.git
cd microurl
python setup.py install
开始
首先,你要去google或bily或supr注册一个应用程序
注册后,从“应用程序详细信息”选项卡中获取应用程序Consumer Key和Consumer Secret
首先,您需要从microurl导入所需的minfier
frommicrourlimportgoogle_mini
google mini的基本用法
函数定义(即google_mini())可以通过阅读microurl/google.py找到
minified=google_mini('validurl','Google_API_KEY')
就这么简单。
二维码发生器
qr_url=qrcode(url)
Bitly的身份验证
frommicrourlimportbitlyauthenticationauthentication=bitlyauthentication(client_id,client_secret,redirect_uri)auth_url=authentication.authorization_url()
在浏览器中打开auth_url。授权应用程序后,将重定向到使用代码perameter重定向url。
access_token=authentication.get_accesstoken_from_code(code)# code that you get to redirect_url in the above step
使用用户名和密码进行身份验证
access_token=authentication.get_accesstoken_from_username_pwd(bitlyusernameorloginemail,password)
Bitly的基本用法
函数定义(即shorturl())可以通过读取microurl/bitly.py找到
获取bitlylink的详细信息。 获取单个位链接的单击次数。 获取单个位链接上的共享数。 获取loggedin用户信息 按时间倒序获取用户链接历史。frommicrourlimportbitlyapibitly=bitlyapi(access_token)# access_token is getting from previous stepsminified=bitly.shorturl(longurl,domain)['url']# domain is optional here
bitly.url_info(bitlylink,expand_user='True | False',hash='one or more bitly hashes')# expand_user,hash are optional here
bitly.link_clicks(bitlylink,unit="day",units=10,timezone=-4,limit=20,unit_reference_ts="now")# here except bitlylink all are optional
bitly.link_shares(bitlylink,unit="day",units=10,timezone=-4,limit=20,unit_reference_ts="now")# here except bitlylink all are optional
bitly.user_info()
bitly.user_linkhistory(bitlylink,limit=20,offset=1,created_after='1381000000',created_before='1381844314',expand_client_id=True,archived="both",private="both")# here all fields are optional
想帮忙吗?
microurl是有用的,但最终只能和使用它的人一样有用(比如说十倍的速度!)。如果你想提供帮助,请编写示例代码、提供修补程序、在wiki上记录内容、在tweet上发布相关信息。感谢您的帮助!