可以查询五笔的网站很多,还是觉得不方便,本来想利用一个字典,实现本地查询,结果没找到。下面是一个用Python写的从在线查询汉字五笔编码和拼音的程序。
#!/usr/bin/env python #coding=utf-8 #author: Jianjun Kong #website: import urllib,cookielib,urllib2,httplib import sys,string,os web_url = "" web_url += "wb/wb.asp?" str=string.join(sys.argv[1:],'') def init(): cookie = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) exheaders = [("User-Agent","Firefox/3.05 (X11; Linux x86_64; U;en)"),("Connection","Keep-Alive"),("Referer",""),("Accept","text/html,application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg,image/gif, image/x-xbitmap, */*;q=0.1"),("Accept-Charset","iso-8859-1,utf-8, utf-16, *;q=0.1"),("Cookie2","$Version=1"),] opener.addheaders = exheaders urllib2.install_opener(opener) return opener def search(opener): global web_url,str body = (("querykey",str.decode('utf-8').encode('gb2312')),) ret = opener.open(web_url,urllib.urlencode(body)) str=ret.read() str=str.decode('gb2312').encode('utf-8') f=open("/tmp/wubi.tmp","w") f.write("%s" %(str)) f.close() def main(argv=None): opener=init() search(opener) cmds=''' sed -i -e '1,/