=== Description The aim of the following code is to translate English word to Chinese, which is based on iciba.com API. === Code {{{ #! /usr/bin/python import urllib,sys url="http://dict-co.iciba.com/api/dictionary.php?w=" if len( sys.argv ) > 1: url +=sys.argv[1] else : print "please input your searching word..." sys.exit(1) #get the chinese explaination content from iciba.com file=urllib.urlopen( url ) content = file.read() file.close() #extract the explaination from the content acceptation="" arr=() content=content.partition("<acceptation>")[2] while content : arr = content.partition("</acceptation>") acceptation +=arr[0] + " " content = arr[2].partition("<acceptation>")[2] #print re.sub( ' $','', acceptation ) print acceptation.rstrip(' ') #Writing unknown words into a file for later reviewing dat="dict.dat" #store unknown words #if !os.path.isfile( dat ) file = open( dat, "a") file.writelines( " "+sys.argv[1] ) file.close() }}} === Requirements: Internet, python === Usuage {{{ ./dict hello }}} You can also add {{{ alias dict=yourhomefolder/dict }}} into your bash file(for Mac //.bash_profile// and for Ubuntu //.bashrc//), then you can just type //dict hello// to get your translation.