简洁的Conky天气代码:中国天气网

仅供存放个人的配置文件,不要在本版发问。
回复
oldoldstone
帖子: 190
注册时间: 2009-08-05 11:38

简洁的Conky天气代码:中国天气网

#1

帖子 oldoldstone » 2011-07-14 11:09

无需额外脚本,只要贴到conkyrc中即可生效,不支持图片。
1. 使用前提是可以上网(自己可以加拨号判断),有curl 和 sed。
2. 默认城市是北京,可以修改第一行链接,具体城市代码到http://www.weather.com.cn/上查
3. 天气部分字体使用的是微软雅黑,没有可以自己自行修改,不过微米黑的°显示不了。

代码: 全选

${execi 600 curl -s --connect-timeout 30 "http://wap.weather.com.cn/data/sk/101010100.html" >/tmp/current }${execi 6000 curl -s --connect-timeout 30 "http://m.weather.com.cn/data/101010100.html" >/tmp/forcast }
${voffset -29}${goto 32}${execi 600 sed  's/^.*"city":"//' /tmp/current | sed 's/",".*$//' }: ${color1}${execi 600 sed  's/^.*"img_title_single":"//' /tmp/forcast | sed 's/",".*$//' } ${execi 600 sed  's/^.*"temp":"//' /tmp/current | sed 's/",".*$//' }°C ${execi 600 sed  's/^.*"WD":"//' /tmp/current | sed 's/",".*$//' }, ${execi 600 sed  's/^.*"time":"//' /tmp/current | sed 's/",".*$//' }${color} 
${goto 32}${font Microsoft YaHei:size=9}今日: ${color1}${execi 600 sed  's/^.*"weather1":"//' /tmp/forcast | sed 's/",".*$//' } ${execi 600 sed  's/^.*"temp1":"//' /tmp/forcast | sed 's/",".*$//' }${color}${font}
${goto 32}${font Microsoft YaHei:size=9}明日: ${color1}${execi 600 sed  's/^.*"weather2":"//' /tmp/forcast | sed 's/",".*$//' } ${execi 600 sed  's/^.*"temp2":"//' /tmp/forcast | sed 's/",".*$//' }${color}${font}
${goto 32}${font Microsoft YaHei:size=9}后日: ${color1}${execi 600 sed  's/^.*"weather3":"//' /tmp/forcast | sed 's/",".*$//' } ${execi 600 sed  's/^.*"temp3":"//' /tmp/forcast | sed 's/",".*$//' }${color}${font}

color1 2为自定义颜色,可自行修改

代码: 全选

color1 ffe7ba
附件
无标题.jpg
无标题.jpg (11.22 KiB) 查看 9618 次
上次由 oldoldstone 在 2011-07-14 11:36,总共编辑 1 次。
头像
nmsfan
帖子: 18958
注册时间: 2009-10-16 22:46
来自: finland

Re: 简洁的Conky天气代码:中国天气网

#2

帖子 nmsfan » 2011-07-14 11:12

可以试试~~~~
>>>>推Ubuntu 桌面培训~~<<<<
>>>>想加入/了解gimp汉化吗,点我吧~<<<<
——————————————————————
不推荐wubi,也不推荐你给别人推荐wubi…………
随心而为的感觉真好……
强推mayhem!!
强推ensiferum
头像
qy117121
论坛版主
帖子: 50587
注册时间: 2007-12-14 13:40
系统: Winbuntu
来自: 志虚国乌由市
联系:

Re: 简洁的Conky天气代码:中国天气网

#3

帖子 qy117121 » 2011-07-14 11:12

不错,不用额外的脚本 :em11
渠月 · QY   
本人只会灌水,不负责回答问题
无聊可以点一下→ http://u.nu/ubuntu

邮箱 chuan@ubuntu.org.cn
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: 简洁的Conky天气代码:中国天气网

#4

帖子 leeaman » 2011-07-14 11:15

这个网址好,ee来看看,这个好不?赞换网址好不好呀
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
头像
monk
帖子: 19507
注册时间: 2010-01-28 10:45

Re: 简洁的Conky天气代码:中国天气网

#5

帖子 monk » 2011-07-14 11:22

不错 收藏了 :em11

*********宁静致远*********
如果我说的有什么不对,请看签名第一行
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 简洁的Conky天气代码:中国天气网

#6

帖子 eexpress » 2011-07-14 11:24

容易处理些。1234这些,就是按次序排的天气?

代码: 全选

● cat w|perl -e '$_=<STDIN>; s/[{},]/\n/g; s/:/\t->\t/g; print'

"weatherinfo"	->	
"city"	->	"北京"
"city_en"	->	"beijing"
"date_y"	->	"2011年7月14日"
"date"	->	"辛卯年"
"week"	->	"星期四"
"fchh"	->	"11"
"cityid"	->	"101010100"
"temp1"	->	"31℃~22℃"
"temp2"	->	"30℃~22℃"
"temp3"	->	"31℃~22℃"
"temp4"	->	"31℃~23℃"
"temp5"	->	"30℃~22℃"
"temp6"	->	"31℃~23℃"
"tempF1"	->	"87.8℉~71.6℉"
"tempF2"	->	"86℉~71.6℉"
"tempF3"	->	"87.8℉~71.6℉"
"tempF4"	->	"87.8℉~73.4℉"
"tempF5"	->	"86℉~71.6℉"
"tempF6"	->	"87.8℉~73.4℉"
"weather1"	->	"雷阵雨"
"weather2"	->	"阵雨"
"weather3"	->	"多云转雷阵雨"
"weather4"	->	"阵雨"
"weather5"	->	"阵雨转阴"
"weather6"	->	"阴"
"img1"	->	"4"
"img2"	->	"99"
"img3"	->	"3"
"img4"	->	"99"
"img5"	->	"1"
"img6"	->	"4"
"img7"	->	"3"
"img8"	->	"99"
"img9"	->	"3"
"img10"	->	"2"
"img11"	->	"2"
"img12"	->	"99"
"img_single"	->	"4"
"img_title1"	->	"雷阵雨"
"img_title2"	->	"雷阵雨"
"img_title3"	->	"阵雨"
"img_title4"	->	"阵雨"
"img_title5"	->	"多云"
"img_title6"	->	"雷阵雨"
"img_title7"	->	"阵雨"
"img_title8"	->	"阵雨"
"img_title9"	->	"阵雨"
"img_title10"	->	"阴"
"img_title11"	->	"阴"
"img_title12"	->	"阴"
"img_title_single"	->	"雷阵雨"
"wind1"	->	"微风"
"wind2"	->	"微风"
"wind3"	->	"微风"
"wind4"	->	"微风"
"wind5"	->	"微风"
"wind6"	->	"微风"
"fx1"	->	"微风"
"fx2"	->	"微风"
"fl1"	->	"小于3级"
"fl2"	->	"小于3级"
"fl3"	->	"小于3级"
"fl4"	->	"小于3级"
"fl5"	->	"小于3级"
"fl6"	->	"小于3级"
"index"	->	"炎热"
"index_d"	->	"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。"
"index48"	->	"炎热"
"index48_d"	->	"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。"
"index_uv"	->	"中等"
"index48_uv"	->	"中等"
"index_xc"	->	"不宜"
"index_tr"	->	"一般"
"index_co"	->	"较不舒适"
"st1"	->	"29"
"st2"	->	"19"
"st3"	->	"28"
"st4"	->	"20"
"st5"	->	"31"
"st6"	->	"20"
"index_cl"	->	"较不宜"
"index_ls"	->	"不宜"

● 鸣学
头像
qy117121
论坛版主
帖子: 50587
注册时间: 2007-12-14 13:40
系统: Winbuntu
来自: 志虚国乌由市
联系:

Re: 简洁的Conky天气代码:中国天气网

#7

帖子 qy117121 » 2011-07-14 11:25

:em70 来了
渠月 · QY   
本人只会灌水,不负责回答问题
无聊可以点一下→ http://u.nu/ubuntu

邮箱 chuan@ubuntu.org.cn
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: 简洁的Conky天气代码:中国天气网

#8

帖子 leeaman » 2011-07-14 11:26

现在这个主要是九点才更新,NNNND的,八点上班看昨天的天气实在不爽呐
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
oldoldstone
帖子: 190
注册时间: 2009-08-05 11:38

Re: 简洁的Conky天气代码:中国天气网

#9

帖子 oldoldstone » 2011-07-14 11:31

eexpress 写了:容易处理些。1234这些,就是按次序排的天气?

代码: 全选

● cat w|perl -e '$_=<STDIN>; s/[{},]/\n/g; s/:/\t->\t/g; print'

"weatherinfo"	->	
"city"	->	"北京"
"city_en"	->	"beijing"
"date_y"	->	"2011年7月14日"
"date"	->	"辛卯年"
"week"	->	"星期四"
"fchh"	->	"11"
"cityid"	->	"101010100"
"temp1"	->	"31℃~22℃"
"temp2"	->	"30℃~22℃"
"temp3"	->	"31℃~22℃"
"temp4"	->	"31℃~23℃"
"temp5"	->	"30℃~22℃"
"temp6"	->	"31℃~23℃"
"tempF1"	->	"87.8℉~71.6℉"
"tempF2"	->	"86℉~71.6℉"
"tempF3"	->	"87.8℉~71.6℉"
"tempF4"	->	"87.8℉~73.4℉"
"tempF5"	->	"86℉~71.6℉"
"tempF6"	->	"87.8℉~73.4℉"
"weather1"	->	"雷阵雨"
"weather2"	->	"阵雨"
"weather3"	->	"多云转雷阵雨"
"weather4"	->	"阵雨"
"weather5"	->	"阵雨转阴"
"weather6"	->	"阴"
"img1"	->	"4"
"img2"	->	"99"
"img3"	->	"3"
"img4"	->	"99"
"img5"	->	"1"
"img6"	->	"4"
"img7"	->	"3"
"img8"	->	"99"
"img9"	->	"3"
"img10"	->	"2"
"img11"	->	"2"
"img12"	->	"99"
"img_single"	->	"4"
"img_title1"	->	"雷阵雨"
"img_title2"	->	"雷阵雨"
"img_title3"	->	"阵雨"
"img_title4"	->	"阵雨"
"img_title5"	->	"多云"
"img_title6"	->	"雷阵雨"
"img_title7"	->	"阵雨"
"img_title8"	->	"阵雨"
"img_title9"	->	"阵雨"
"img_title10"	->	"阴"
"img_title11"	->	"阴"
"img_title12"	->	"阴"
"img_title_single"	->	"雷阵雨"
"wind1"	->	"微风"
"wind2"	->	"微风"
"wind3"	->	"微风"
"wind4"	->	"微风"
"wind5"	->	"微风"
"wind6"	->	"微风"
"fx1"	->	"微风"
"fx2"	->	"微风"
"fl1"	->	"小于3级"
"fl2"	->	"小于3级"
"fl3"	->	"小于3级"
"fl4"	->	"小于3级"
"fl5"	->	"小于3级"
"fl6"	->	"小于3级"
"index"	->	"炎热"
"index_d"	->	"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。"
"index48"	->	"炎热"
"index48_d"	->	"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。"
"index_uv"	->	"中等"
"index48_uv"	->	"中等"
"index_xc"	->	"不宜"
"index_tr"	->	"一般"
"index_co"	->	"较不舒适"
"st1"	->	"29"
"st2"	->	"19"
"st3"	->	"28"
"st4"	->	"20"
"st5"	->	"31"
"st6"	->	"20"
"index_cl"	->	"较不宜"
"index_ls"	->	"不宜"

是的,这是借鉴了手机上cmtianqi的方法,其实支持图片也很容易的,img有对应的index的图片,搜索cmtianqi即可。
不过考虑到perl或者python有些人可能没装,直接用sed的,看起来有点难看,不过凑合能用了,
神可以来写个更好的 :em11
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 简洁的Conky天气代码:中国天气网

#10

帖子 eexpress » 2011-07-14 12:28

这网站我早看过,没看到找城市编码的说明。才也没找到。

没perl的系统,估计只有windows。
● 鸣学
oldoldstone
帖子: 190
注册时间: 2009-08-05 11:38

Re: 简洁的Conky天气代码:中国天气网

#11

帖子 oldoldstone » 2011-07-14 12:43

附带的cmtianqi的城市编码列表和图片。
第一个是中国天气网的code。
附件
img.7z
(3.74 MiB) 已下载 195 次
citycode.bz2
(22.99 KiB) 已下载 220 次
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 简洁的Conky天气代码:中国天气网

#12

帖子 eexpress » 2011-07-14 20:32

citycode.bz2 哪里下的。给个url吧。
如果要作,我会自己去自动获取。现在这些网站,都不搞自动识别ip的。
天气居然是43的。

还分层的编码
http://hi.baidu.com/gushu/blog/item/665 ... 947c0.html

与我脚本里面需要的格式,差了日期。还要专门插入日期。暂时不搞了。

代码: 全选

>	2011-7-14	雷阵雨	24°C	西北风微风
 	2011-7-15	雷阵雨	31°C-25°C	西北风微风/无持续风向微风
-	2011-7-16	雷阵雨	33°C-25°C	无持续风向微风/北风微风
-	2011-7-17	雷阵雨	30°C-25°C	北风微风
 	2011-7-18	雷阵雨	32°C-26°C	北风微风
 	2011-7-19	雷阵雨	32°C-26°C	北风微风
 	2011-7-20	雷阵雨	32°C-26°C	北风微风
 	2011-7-21	雷阵雨	34°C	北风微风		

代码: 全选

● cat 101250101.html |perl -e '$_=<STDIN>; s/"//g; %a=map{split /:/} grep /weather\d|wind\d|temp\d/, split /[{},]/s; for $i (1..6){print "$a{weather.$i}\t$a{temp.$i}\t\t$a{wind.$i}\n";}'
雷阵雨	24℃~31℃		西北风小于3级
雷阵雨	25℃~33℃		微风
雷阵雨	25℃~30℃		北风小于3级
雷阵雨	25℃~32℃		北风小于3级
雷阵雨	26℃~32℃		北风小于3级
雷阵雨	26℃~32℃		北风小于3级
● 鸣学
头像
月下叹逍遥
论坛版主
帖子: 33994
注册时间: 2010-10-07 14:23
系统: Archdows10
来自: 某系某星某洲某国某省某市
联系:

Re: 简洁的Conky天气代码:中国天气网

#13

帖子 月下叹逍遥 » 2011-07-14 20:37

:em70
浮生七十今三十,从此凄惶未可知
oldoldstone
帖子: 190
注册时间: 2009-08-05 11:38

Re: 简洁的Conky天气代码:中国天气网

#14

帖子 oldoldstone » 2011-07-15 9:46

没有,我也是从软件里抠的,不知道出处,本地查表吧
eexpress 写了:citycode.bz2 哪里下的。给个url吧。
如果要作,我会自己去自动获取。现在这些网站,都不搞自动识别ip的。
天气居然是43的。

还分层的编码
http://hi.baidu.com/gushu/blog/item/665 ... 947c0.html

与我脚本里面需要的格式,差了日期。还要专门插入日期。暂时不搞了。

代码: 全选

>	2011-7-14	雷阵雨	24°C	西北风微风
 	2011-7-15	雷阵雨	31°C-25°C	西北风微风/无持续风向微风
-	2011-7-16	雷阵雨	33°C-25°C	无持续风向微风/北风微风
-	2011-7-17	雷阵雨	30°C-25°C	北风微风
 	2011-7-18	雷阵雨	32°C-26°C	北风微风
 	2011-7-19	雷阵雨	32°C-26°C	北风微风
 	2011-7-20	雷阵雨	32°C-26°C	北风微风
 	2011-7-21	雷阵雨	34°C	北风微风		

代码: 全选

● cat 101250101.html |perl -e '$_=<STDIN>; s/"//g; %a=map{split /:/} grep /weather\d|wind\d|temp\d/, split /[{},]/s; for $i (1..6){print "$a{weather.$i}\t$a{temp.$i}\t\t$a{wind.$i}\n";}'
雷阵雨	24℃~31℃		西北风小于3级
雷阵雨	25℃~33℃		微风
雷阵雨	25℃~30℃		北风小于3级
雷阵雨	25℃~32℃		北风小于3级
雷阵雨	26℃~32℃		北风小于3级
雷阵雨	26℃~32℃		北风小于3级
头像
秋景雨
帖子: 137
注册时间: 2011-01-31 12:55
联系:

Re: 简洁的Conky天气代码:中国天气网

#15

帖子 秋景雨 » 2012-05-16 21:29

:em11 这个太好了,太强大了,完全可以自己动手,不仅可以用于桌面,还可以用于网页。今天收获太大了。
回复