恰巧发现有个叫“EarthLiveSharp”,可用将日本向日葵8号卫星的地球实时图片设为屏保。向日葵8号卫星的地球实时图片官网为:http://himawari8.nict.go.jp/,EarthLiveSharp的项目地址是:https://github.com/bitdust/EarthLiveSharp。
为了减轻向日葵8号的服务器负担,同时也是提高地球实时图片的获取成功率,需要使用cloudinary来做CDN。注册配置都在软件里有说明。
目前EarthLiveSharp暂时没有清理cloudinary的CDN图片缓存的功能,于是我用python写了一个,并尝试用gist管理,地址为:https://gist.github.com/creke/c5a8a18fa41b8f5c1a0719a7e0cf4de6
同时,为了大家方便,顺便编译成了Windows可执行文件,下载: https://pan.baidu.com/s/1c27fXEo 提取码:k33n
为了自己检索方便,顺便在这里附上python脚本源码,可以作为python如何使用RESTful接口的例子,相关工具类函数也便于参考。
EarthLiveCleanCloudinary.py
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# -*- coding: utf-8 -*-
# Author: Creke
# HomePage: http://blog.creke.net
import sys
import urllib, urllib2
import base64
import json
URLLIB_DEBUG_LEVEL = 1
URLLIB_TIMEOUT = 5
def Dict2Uri(dic):
return urllib.urlencode(dic)
def GenUrllibReq(url, method, api_key, api_secret, post_data = None ):
urlreq = None
if post_data is None :
urlreq = urllib2.Request(url)
else :
urlreq = urllib2.Request(url, post_data)
urlreq.get_method = lambda : method
auth_str = base64.b64encode( '%s:%s' % (api_key, api_secret))
urlreq.add_header( "Authorization" , "Basic %s" % auth_str)
urlreq.add_header( 'Cache-Control' , 'no-cache' )
return urlreq
def GetApiDelUrl(cloud_name, img_type):
url = "https://api.cloudinary.com/v1_1/%s/resources/image/%s" % (cloud_name, img_type)
params = { "prefix" : "http://himawari8-dl" }
url = url + "?" + Dict2Uri(params)
return url
def main(argv):
arg_idx = 1
api_key = argv[arg_idx]
arg_idx + = 1
api_secret = argv[arg_idx]
arg_idx + = 1
cloud_name = argv[arg_idx]
while True :
del_url = GetApiDelUrl(cloud_name, 'fetch' )
urlreq = GenUrllibReq(del_url, 'DELETE' , api_key, api_secret)
print "==========================="
print "Requesting %s" % (del_url)
opener = urllib2.build_opener(urllib2.HTTPSHandler(debuglevel = URLLIB_DEBUG_LEVEL))
urllib_open = opener. open (urlreq, timeout = URLLIB_TIMEOUT)
response = urllib_open.read()
print "==========================="
print "Response:"
print "%s" % (response)
print "==========================="
urllib_open.close()
print "Done Requesting"
res_json = json.loads(response)
deleted_cnt = len (res_json[ 'deleted' ])
print "Deleted %u himawari8 pics" % (deleted_cnt)
print "==========================="
if 'next_cursor' in res_json and deleted_cnt> 0 :
print "Due to Cloudinary limits, we're starting a new round"
else :
break
return 0
def PrintHelp(argv):
print "\\t USAGE: %s [api_key] [api_secret] [cloud_name]" % (argv[ 0 ])
if __name__ = = '__main__' :
if len (sys.argv) < 4 :
PrintHelp(sys.argv)
exit( 1 )
print "RUNNING main"
main(sys.argv)
print "DONE main"
|
EarthLiveCleanCloudinary2exe.py
?
1
2
3
4
5
6
7
8
|
# -*- coding: utf-8 -*-
# Author: Creke
# HomePage: http://blog.creke.net
from distutils.core import setup
import py2exe
setup(console = [ 'EarthLiveCleanCloudinary.py' ])
|
Windows编译版本下载:
链接: https://pan.baidu.com/s/1skADZeH 密码: rdgb
相关文章
猜你喜欢
- ASP.NET自助建站系统中如何实现多语言支持? 2025-06-10
- 64M VPS建站:如何选择最适合的网站建设平台? 2025-06-10
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-06-04 80
-
怎样在Windows Server 2008上监控网站流量和日志?
2025-05-25 94 -
2025-06-04 79
-
2025-05-27 51
-
2025-05-29 103
热门评论