忘记从哪里找的代码拼凑的百度翻译,感兴趣的可以拿去试试,需要自己申请百度api
https://fanyi-api.baidu.com/product/113
YC:MD5这个函数是哪个大神的代码,有知道的麻烦说一下,我好注明出处
输入(baidu-translate "HELLO WORLD")
输出"{\"from\":\"en\",\"to\":\"zh\",\"trans_result\":[{\"src\":\"HELLO
WORLD\",\"dst\":\"\\u4f60\\u597d\\u4e16\\u754c\"}]}"
- (defun baidu-translate(str)
- (setq appid "2022100800*******"
- salt "143*******"
- key "b9A6Eyw00P1jJ*******"
- )
- (setq sign(YC:MD5 (strcat appid str salt key)))
- (progn
- (vl-load-com)
- (setq obj(vlax-create-object (strcat"win""http"".win""http""request.5.1")))
- (vlax-invoke obj'open "get" (strcat "http://api.fanyi.baidu.com/api/trans/vip/translate?q="
- str "&from=en&to=zh&appid="appid "&salt="salt "&sign="sign
- ):vlax-true)
- (vlax-invoke obj'send)
- (vlax-invoke obj 'WaitforResponse 1000)
- (setq dst(vlax-get obj 'ResponseText))
- )
- )
|