说明:
1: http://www.hzqx.com/gzhfw/dqyb.asp是杭州气象网的短期预报页,页面简单,预报准确,童叟无期.....
2: 代码写得极其丑陋,不过可以工作 (fc6+gvim72)
1: http://www.hzqx.com/gzhfw/dqyb.asp是杭州气象网的短期预报页,页面简单,预报准确,童叟无期.....
2: 代码写得极其丑陋,不过可以工作 (fc6+gvim72)
"==================================================
" File: SzWeather.vim
" Brief: 山寨版气象预报
" Authors: shrek<shrek.wang AT gmail DOT com>
" Last Change: 2009-02-14 21:14:00
" Version: 0.00000000000000000000000000000001
" Licence: LGPL
"
"
" Usage: 1:编辑任意文件
" 2:用 ,gw 来打开气象预报
function! GetWeather()
python << EOF
import vim
import re
import urllib
vim.command("call SwitchToWeatherResult()")
url="http://www.hzqx.com/gzhfw/dqyb.asp"
f = urllib.urlopen(url)
content = f.read()
f.close()
content=content.decode("GBK")
pattern=" "
start= content.find(pattern);
end= content.find("</td>",start);
weatherInfo=content[start:end].replace(" ","")
lines=weatherInfo.encode("UTF8").split("\n")
for line in lines:
vim.current.buffer.append(line)
EOF
endfunction
function! SwitchToWeatherResult()
let s:cur_buf = bufnr("%")
let s:szdb_result_buf=bufnr("SzdbResult")
if bufwinnr(s:szdb_result_buf) > 0
exec bufwinnr(s:szdb_result_buf) . "wincmd w"
%d
else
exec 'silent! botright split SzWeatherResult'
exec "e SzWeatherResult"
exec "set wrap"
exec "map d :bd!<cr>"
endif
endfunction
map <silent> ,gw :call GetWeather()<cr>