要考英语了, 单词一大堆, 索性就用Python自动到网上找单词的中文意思了~.
目前只是盲目的摘下来而已. 
    写的过程中,终于知道编码问题是多么的严重了. 下次一定要用chardet这个库了,方便快捷...

InBlock.gif # http://dict.youdao.com/search?q=hello&tab=chn&keyfrom=dict.result can' use it , be-
InBlock.gif # cause it is python's bug
InBlock.gifimport urllib
InBlock.giffrom BeautifulSoup import BeautifulSoup
InBlock.gifimport sys
InBlock.gifglobal    file
InBlock.gif
def getWebContent(url, word):
InBlock.gif        html = urllib.urlopen(url).read()
InBlock.gif        #html = html.decode("gb2312","ignore").encode("utf-8","ignore")
InBlock.gif        html = unicode(html,"gb2312","ignore").encode("utf-8","ignore")
InBlock.gif        soup = BeautifulSoup(html)
InBlock.gif    
InBlock.gif        #filter 1
InBlock.gif        data = str(soup.find("div", {"class":"explain"}))
InBlock.gif        #strContent = data.renderContents()+"\n" # default the string s is coded with ASCII
InBlock.gif                                                                                                     # but the original is UTF-8, because the
InBlock.gif                                                                                                     # beautifulSoup use it...
InBlock.gif        #fileter 2
InBlock.gif        soup = BeautifulSoup(data)
InBlock.gif        # beautifulsoup generator http://www.crummy.com/software/BeautifulSoup/documentation.zh.html#Generators
InBlock.gif        outtext=''.join([element    for element in soup.recursiveChildGenerator() if isinstance(element,unicode)])
InBlock.gif        #make some rendering
InBlock.gif        for item in range(1,10):
InBlock.gif                outtext=outtext.replace(str(item),"\n%s" % str(item))
InBlock.gif        outtext=outtext.replace("    ","\n")
InBlock.gif        outtext =word +":\n" +outtext +"\n"
InBlock.gif        file.write(outtext)
InBlock.gif        print outtext.decode("utf-8").encode("gbk")
InBlock.gif

InBlock.gifdef word_FromFile():
InBlock.gif        file = open("F:/Whu/EnghlishWords.txt","r")
InBlock.gif        for word in file.readlines():
InBlock.gif                print isinstance(word, unicode)
InBlock.gif                print word.decode("utf-8")
InBlock.gif
                #must be carefully!!!
InBlock.gif                #because we use the utf-8 to store the Chinese words in notepad
InBlock.gif                #it will add another 3 words to mark
InBlock.gif                #     if file[:3] == codes.BOM_UTF8;
InBlock.gif                #            data = data[3:]
InBlock.gif                #            print data.decode("utf-8")
InBlock.gif                
InBlock.gif                url = "http://dict.baidu.com/s?wd=%s" % word
InBlock.gif                getWebContent(url, word)
InBlock.gifif __name__ == '__main__':
InBlock.gif        reload(sys)
InBlock.gif        sys.setdefaultencoding('utf-8')
InBlock.gif        file = open("F:/Whu/EnghlishWords_translate.txt",'w')
InBlock.gif        word_FromFile()
InBlock.gif        file.flush()
InBlock.gif        file.close()
InBlock.gif