»
首页
|
手机数码
|
汽车资讯
|
游戏硬件
|
评测专题
|
手机壁纸
|
海淘值得买
|
度假
|
求职招聘
|
广告联系
» 您尚未登录:请
登录
|
注册
|
标签
|
帮助
|
小黑屋
|
TGFC Lifestyle
»
完全数码讨论区
» 中年入门程序员作品,Mac下自动下载Bing每日墙纸的Python script,16楼
发新话题
发布投票
发布商品
发布悬赏
发布活动
发布辩论
发布视频
打印
[其他]
中年入门程序员作品,Mac下自动下载Bing每日墙纸的Python script,16楼
zj14
侠客
帖子
310
精华
0
积分
20512
激骚
192 度
爱车
主机
相机
手机
注册时间
2009-2-25
发短消息
加为好友
当前离线
1
#
大
中
小
发表于 2013-9-25 16:43
显示全部帖子
posted by wap, platform: Chrome
#!/usr/bin/env python
import os
import pprint
import sys
import subprocess
import urllib2
from time import strftime
from urllib import URLopener
from urllib2 import urlopen
from xml.dom.minidom import parseString
# Defines source and destination of image
#rss_feed = 'http://feeds.feedburner.com/bingimages';
url = 'http://www.bing.com'
size = '1920x1080'
dst_dir = os.path.expanduser('~/Pictures/DeskFeed/')
# Originally found on: http://hints.macworld.com/article.php?story=20110721062846337
# Applescript modified for dual monitors by: ViVIDboarder
SCRIPT = """/usr/bin/osascript<<end
tell application "System Events"
set picture of every desktop to POSIX file "%s"
end tell
END"""
def set_desktop_background(destination):
subprocess.Popen(SCRIPT%destination, shell=True)
def parseFeed(url):
destination = "%s%s.jpg" % (dst_dir, strftime( "%y-%m-%d"
)
if os.path.exists(destination):
sys.exit(0)
req = urllib2.Request(url)
content = urllib2.urlopen(req).read()
link = content[content.index('g_img={url:') + len('g_img={url:') + 1 : len(content)]
link = link[0 : link.index(',id:') - 1]
links = link.split('_')
link = links[0] + '_' + links[1] + '_' + size + '.jpg'
print link
URLopener().retrieve(link, destination)
set_desktop_background(destination)
def main():
parseFeed(url)
if __name__ == "__main__":
main();
本帖最近评分记录
eva3d
激骚
+5
感谢分享
2013-9-26 08:56
UID
121495
帖子
310
精华
0
积分
20512
交易积分
0
阅读权限
40
在线时间
6733 小时
注册时间
2009-2-25
最后登录
2025-7-7
查看详细资料
TOP
控制面板首页
密码修改
积分交易
积分记录
公众用户组
基本概况
版块排行
主题排行
发帖排行
积分排行
交易排行
在线时间
管理团队
管理统计