Python就是爽啊,用来抓网页信息是再合适不过了。今天结合小甲鱼的视频做了一个简易翻译工具,大牛勿喷,仅供娱乐!^_^
主要用到的模块是json和easyGUI,结合网易有道翻译的网页制作而成。效果还可以。
# Powered By KunSoft
# 2015年2月27日
from urllib.request import *
from urllib.parse import *
import easygui as g
import json
while True:
content = g.enterbox(msg='输入要翻译的内容', title='简易翻译器') #显示GUI界面,读入输入信息
if content == None: #如果点击关闭按钮,退出程序
exit(0)
#有道词典翻译链接
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=http://www.youdao.com/'
#上传信息并编码为utf-8格式
data = {'type':'AUTO', 'i':content, 'doctype'