forked from health901/AHK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
有道翻译API.ahk
36 lines (32 loc) · 933 Bytes
/
有道翻译API.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;
; AHK版本: B:1.0.48.5
; L:1.1.3.0
; 语言: 中文/English
; 平台: Win7
; 作者: 海盗 <healthlolicon@gmail.com>
;
;
;
;
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir% ;
#Include C:\Users\Robin\Documents\AutoHotKey\Lib\codexchange.ahk
keyfrom=你注册时填写的keyfrom
APIKEY=你的APIKEY
ansi_cn=中国
ansi_en=speak
;转码
utf8_cn:=Ansi2UTF8(ansi_cn)
utf8_en:=Ansi2UTF8(ansi_en)
;url编码
url_cn:=UrlEncode(utf8_cn)
url_en:=UrlEncode(utf8_en)
;get
/*
http://fanyi.youdao.com/fanyiapi.do?keyfrom=<WebSiteName(keyfrom)>&key=<API KEY>&type=data&doctype=json&version=1.1&q=
*/
var1:=URLDownloadTovar("http://fanyi.youdao.com/fanyiapi.do?keyfrom=" . keyfrom . "&key=" . APIKEY . "&type=data&doctype=json&version=1.1&q=" . url_cn)
MsgBox,% UTF82Ansi(var1)
var2:=URLDownloadTovar("http://fanyi.youdao.com/fanyiapi.do?keyfrom=" . keyfrom . "&key=" . APIKEY . "&type=data&doctype=json&version=1.1&q=" . url_en)
MsgBox,% UTF82Ansi(var2)