|
『Node-RED』百度翻译!
直接上效果!@哈哈!@!@!@
先去百度翻译申请:http://api.fanyi.baidu.com/api/trans/product/prodinfo#0
记录:APPID 密码
导入流程:
[{"id":"26201c99.959cf4","type":"tab","label":"流程7","disabled":false,"info":""},{"id":"34e785b6.e3573a","type":"function","z":"26201c99.959cf4","name":"百度参数设置","func":"//须要翻译的内内容\nmsg.q = '苹果'\n//百度密钥\nvar key = '密钥'\n//APP ID\nmsg.appid = 'APP ID'\nmsg.salt = Math.floor(Math.random()*100000000);\nmsg.sign = msg.appid + msg.q + msg.salt + key\n\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":40,"wires":[["8fe11038.9ff04"]]},{"id":"8fe11038.9ff04","type":"md5","z":"26201c99.959cf4","name":"","fieldToHash":"sign","fieldTypeToHash":"msg","hashField":"sign","hashFieldType":"msg","x":850,"y":40,"wires":[["6bb7b7cc.8f8ca8"]]},{"id":"6bb7b7cc.8f8ca8","type":"function","z":"26201c99.959cf4","name":"参数","func":"msg.headers={\n 'Content-Type':'application/x-www-form-urlencoded;',\n};\n\nmsg.url = 'http://api.fanyi.baidu.com/api/trans/vip/translate?q='+encodeURI(msg.q)+'&from=auto&to=auto&appid='+msg.appid+'&salt='+msg.salt+'&sign='+msg.sign\nreturn msg;","outputs":1,"noerr":0,"x":970,"y":40,"wires":[["455339f1.887f58"]]},{"id":"455339f1.887f58","type":"http request","z":"26201c99.959cf4","name":"","method":"POST","ret":"obj","paytoqs":false,"url":"","tls":"","proxy":"","authType":"basic","x":1100,"y":40,"wires":[["100ea2ea.01a44d"]]},{"id":"100ea2ea.01a44d","type":"debug","z":"26201c99.959cf4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1250,"y":40,"wires":[]},{"id":"3c9f156.0402aea","type":"inject","z":"26201c99.959cf4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":40,"wires":[["34e785b6.e3573a"]]}]
填写 APPID 密码设置要翻译内容!
运行测试!@!@!@!@
哈哈!@!@!@!OK了!@!@!@!@坚决不做申手党!@!@!@
|
-
|