百度,有道,谷歌翻译API

API翻译

百度,有道,谷歌API翻译(只针对中英相互翻译),其他语言翻译需要对应from,to的code

百度翻译

package fills.tools.translate;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Set;

import javax.script.Invocable;

import javax.script.ScriptEngine;

import javax.script.ScriptEngineManager;

import org.apache.http.HttpEntity;

import org.apache.http.NameValuePair;

import org.apache.http.client.entity.UrlEncodedFormEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;

public class BaiduTranslateTools {

public static void main(String[] args) throws Exception{

     String en = doBdTranslate("测试一下", "zh", "en");

     String zh = doBdTranslate("test", "en", "zh");

     System.out.println(en);

     System.out.println(zh);

}

private static CloseableHttpClient httpClient = HttpClients.createDefault();

/**

 * 封装百度翻译请求参数

 * @param query

 * @param from  zh 

 * @param to  en

 * @return String

 * @throws Exception

 */

public static String doBdTranslate(String query,String from,String to)throws Exception{

     String url = "https://fanyi.baidu.com/v2transapi";

     Map<String,String> params = new HashMap<String,String>();

     params.put("from",from);

     params.put("to",to);

     params.put("transtype","translang");

     params.put("simple_means_flag","3");

     params.put("sign",runByJs(query,"sig",getBdJs()));

     params.put("token","75f7eb4170c6dba7a1d84c76611205c3");

     params.put("domain","common");

     params.put("query",query);

     return bdGetResult(bdTranslate(url, params));

}

/**

 * 封装百度翻译接口 模拟浏览器请求

 * @param url

 * @param map

 * @return String

 * @throws Exception

 */

private static String bdTranslate(String url,Map<String,String> map) throws Exception{

        try {

         HttpPost request = new HttpPost(url);

request.setEntity(new UrlEncodedFormEntity(map2list(map), "UTF-8"));

        request.setHeader("Cookie","BIDUPSID=518EFD25B0E401331F59B9BDC8388898; BAIDUID=DA7060B673236FB3427E0D66755262B9:FG=1; PSTM=1636594736; __yjs_duid=1_57b3cd04392832a6fbd32d39e48784831636600728790; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; BDUSS=phdjFZaTJRZ3lPeW1OaHg0WXFyMFgtNWZ6QXNkczh3cEd-Sn5INjg3dG9nc0poRVFBQUFBJCQAAAAAAAAAAAEAAACHLc4ceXNmd3p6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGj1mmFo9ZpheW; H_PS_PSSID=34446_35104_31254_35049_34584_34518_35245_34578_26350_35146; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1637568947; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1637569056; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; delPer=0; PSINO=2; BDRCVFR[Fc9oatPmwxn]=mk3SLVN4HKm; BA_HECTOR=8hag058g0gag8g218f1gpp7gb0r");

        request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0");

        request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

        request.setHeader("Host","fanyi.baidu.com");

        request.setHeader("Origin","https://fanyi.baidu.com");

        request.setHeader("Referer","https://fanyi.baidu.com/?aldtype=16047");

        request.setHeader("X-Requested-With","XMLHttpRequest");

        CloseableHttpResponse response = httpClient.execute(request);

        HttpEntity entity = response.getEntity();

        String result = EntityUtils.toString(entity, "UTF-8");

        EntityUtils.consume(entity);

        response.getEntity().getContent().close();

        response.close();

        return result;

        } catch (Exception e) {

throw e;

}

}

/**

 * 处理百度翻译结果

 * @param json

 * @return

 */

@SuppressWarnings({ "unchecked", "rawtypes" })

private static String bdGetResult(String json){

     Map<String ,Object> result = JSON.parseObject(json, Map.class);

     Map res  = (Map)result.get("trans_result");

     List<Map> r = (List<Map>)res.get("data");

     if(!r.isEmpty()){

          return (r.get(0).get("dst")+"").replace(",", "");

     }

     return null;

}

/**

 *

 * @param param 一个入参

 * @param method 方法

 * @param jsCode js 代码

 * @return String

 */

public static String runByJs(String param,String method,String jsCode){

     String res = null;

     try {

      ScriptEngine bdToken = new ScriptEngineManager().getEngineByName("js");

          bdToken.eval(jsCode);

          Invocable inv2 = (Invocable) bdToken;

          res =(String)inv2.invokeFunction(method,param);

} catch (Exception e) {

 res = null;

}

     return res;

    }

/**

 * 百度js 签名算法

 * @return String

 */

private static String getBdJs(){

StringBuffer bd = new StringBuffer();

bd.append("var i = '320305.131321201';                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ");

bd.append("function n(r, o) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ");

bd.append("    for (var t = 0; t < o.length - 2; t += 3) {                                                                                                                                                                                                                                                                                                                                                                                                                                             ");

bd.append("        var a = o.charAt(t + 2);                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("        a = a >= 'a' ? a.charCodeAt(0) - 87 : Number(a),                                                                                                                                                                                                                                                                                                                                                                                                                                    ");

bd.append("        a = '+' === o.charAt(t + 1) ? r >>> a: r << a,                                                                                                                                                                                                                                                                                                                                                                                                                                      ");

bd.append("        r = '+' === o.charAt(t) ? r + a & 4294967295 : r ^ a                                                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("    return r                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ");

bd.append("var sig = function e(r) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ");

bd.append("    var o = r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g);                                                                                                                                                                                                                                                                                                                                                                                                                                     ");

bd.append("    if (null === o) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("        var t = r.length;                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ");

bd.append("        t > 30 && (r = '' + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr( - 10, 10))                                                                                                                                                                                                                                                                                                                                                                                    ");

bd.append("    } else {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("        for (var e = r.split(/[\uD800-\uDBFF][\uDC00-\uDFFF]/), C = 0, h = e.length, f = []; h > C; C++)'' !== e[C] && f.push.apply(f, a(e[C].split(''))),                                                                                                                                                                                                                                                                                                                                  ");

bd.append("        C !== h - 1 && f.push(o[C]);                                                                                                                                                                                                                                                                                                                                                                                                                                                        ");

bd.append("        var g = f.length;                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ");

bd.append("        g > 30 && (r = f.slice(0, 10).join('') + f.slice(Math.floor(g / 2) - 5, Math.floor(g / 2) + 5).join('') + f.slice( - 10).join(''))                                                                                                                                                                                                                                                                                                                                                  ");

bd.append("    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("    var u = void 0,                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ");

bd.append("    l = '' + String.fromCharCode(103) + String.fromCharCode(116) + String.fromCharCode(107);                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("    u = null !== i ? i: (i = window[l] || '') || '';                                                                                                                                                                                                                                                                                                                                                                                                                                        ");

bd.append("    for (var d = u.split('.'), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) {                                                                                                                                                                                                                                                                                                                                                                     ");

bd.append("        var A = r.charCodeAt(v);                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("        128 > A ? S[c++] = A: (2048 > A ? S[c++] = A >> 6 | 192 : (55296 === (64512 & A) && v + 1 < r.length && 56320 === (64512 & r.charCodeAt(v + 1)) ? (A = 65536 + ((1023 & A) << 10) + (1023 & r.charCodeAt(++v)), S[c++] = A >> 18 | 240, S[c++] = A >> 12 & 63 | 128) : S[c++] = A >> 12 | 224, S[c++] = A >> 6 & 63 | 128), S[c++] = 63 & A | 128)                                                                                                                                  ");

bd.append("    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("    for (var p = m,                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ");

bd.append("    F = '' + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(97) + ('' + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(54)), D = '' + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(51) + ('' + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(98)) + ('' + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(102)), b = 0; b < S.length; b++) p += S[b],        ");

bd.append("    p = n(p, F);                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("    return p = n(p, D),                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ");

bd.append("    p ^= s,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ");

bd.append("    0 > p && (p = (2147483647 & p) + 2147483648),                                                                                                                                                                                                                                                                                                                                                                                                                                           ");

bd.append("    p %= 1e6,                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ");

bd.append("    p.toString() + '.' + (p ^ m)                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ");

return bd.toString();

}

/**

 * 转换请求参数

 * @param paramsMap

 * @return

 */

private static List<? extends NameValuePair> map2list(Map<String, String> paramsMap) {

        List<NameValuePair> listParams = new ArrayList<NameValuePair>();

        Set<String> keys = paramsMap.keySet();

        for (String key : keys) {

             listParams.add(new BasicNameValuePair(key, paramsMap.get(key)));

        }

        return listParams;

    }

}

运行结果

有道翻译

package fills.tools.translate;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Set;

import org.apache.http.HttpEntity;

import org.apache.http.NameValuePair;

import org.apache.http.client.entity.UrlEncodedFormEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;

import fills.tools.md5.MD5Util;

import fills.tools.util.EncodingCheck;

public class YoudaoTranslateTools {

public static void main(String[] args) throws Exception{

        String en = doYdTranslate("测试一下", "zh", "en");

        String zh = doYdTranslate("test", "en", "zh");

        System.out.println(en);

        System.out.println(zh);

}

private static CloseableHttpClient httpClient = HttpClients.createDefault();

/**

 * 封装有道翻译请求参数

 * @param query

 * @param from  zh 

 * @param to  en

 * @return String

 * @throws Exception

 */

public static String doYdTranslate(String query,String from,String to) throws Exception{

        String newQuery = EncodingCheck.gbkToUtf8(query);

        String url = "https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule";

        Long time = System.currentTimeMillis();

       String slat = time+""+ (long) (Math.random() * 10 + 1);

       //签名算法

        String sign = MD5Util.md5("fanyideskweb" + newQuery + slat + "Y2FYu%TNSbMCxc3t2u^XT");

        Map<String,String> params = new HashMap<String,String>();

        params = new HashMap<String,String>();

        params.put("i", newQuery);

        //params.put("from", "AUTO");

        //params.put("to", "AUTO");

        params.put("from", from);

        params.put("to", to);

        params.put("smartresult", "dict");

        params.put("client", "fanyideskweb");

        params.put("salt", slat);

        params.put("sign", sign);

        params.put("doctype", "json");

        params.put("bv","e2a78ed30c66e16a857c5b6486a1d326");

        params.put("lts",""+time);

        params.put("version", "2.1");

        params.put("keyfrom", "fanyi.web");

        params.put("action", "FY_BY_CLICKBUTTION");

       return ydGetResult(YoudaoTranslateTools.ydTranslate(url, params));

}

/**

 * 封装有道翻译接口

 * @param url

 * @param map

 * @return

 * @throws Exception

 */

private static String ydTranslate(String url,Map<String,String> map) throws Exception{

        try {

         HttpPost request = new HttpPost(url);

request.setEntity(new UrlEncodedFormEntity(map2list(map), "UTF-8"));

        request.setHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");

        request.setHeader("Cookie","OUTFOX_SEARCH_USER_ID_NCOO=2112457812.6057248; OUTFOX_SEARCH_USER_ID=\"1568208620@10.105.137.204\"; YOUDAO_MOBILE_ACCESS_TYPE=1; JSESSIONID=aaaj85MpKF2HUbfaqhs1x; ___rl__test__cookies=1637913084476");

        request.setHeader("Host","fanyi.youdao.com");

        request.setHeader("Origin","https://fanyi.youdao.com");

        request.setHeader("Referer","https://fanyi.youdao.com");

        request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0");

        request.setHeader("X-Requested-With","XMLHttpRequest");

        CloseableHttpResponse response = httpClient.execute(request);

        HttpEntity entity = response.getEntity();

        String result = EntityUtils.toString(entity, "UTF-8");

        EntityUtils.consume(entity);

        response.getEntity().getContent().close();

        response.close();

        return result;

        } catch (Exception e) {

throw e;

}

}

/**

 * 处理有道翻译结果

 * @param json

 * @return

 */

@SuppressWarnings({ "unchecked", "rawtypes" })

private static String ydGetResult(String json){

        Map<String ,Object> result = JSON.parseObject(json, Map.class);

        List<List<Map>> res  = (List<List<Map>>)result.get("translateResult");

        if(!res.isEmpty()){

                return res.get(0).get(0).get("tgt")+"";

        }

        return null;

}

/**

 * 转换请求参数

 * @param paramsMap

 * @return

 */

private static List<? extends NameValuePair> map2list(Map<String, String> paramsMap) {

        List<NameValuePair> listParams = new ArrayList<NameValuePair>();

        Set<String> keys = paramsMap.keySet();

        for (String key : keys) {

             listParams.add(new BasicNameValuePair(key, paramsMap.get(key)));

        }

        return listParams;

    }

    

}

运行结果

谷歌翻译

谷歌翻译需要开启国外代理,网络不通

package fills.tools.translate;

import java.util.List;

import javax.script.Invocable;

import javax.script.ScriptEngine;

import javax.script.ScriptEngineManager;

import org.apache.http.HttpEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpGet;

import org.apache.http.client.utils.URIBuilder;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;

public class GoogleTranslateTools {

public static void main(String[] args) throws Exception{

        String en = doGoogleTranslate("测试一下", "zh", "en");

        String zh = doGoogleTranslate("test", "en", "zh");

        System.out.println(en);

        System.out.println(zh);

}

private static CloseableHttpClient httpClient = HttpClients.createDefault();

/**

 * 封装Goole参数信息

 * @param query

 * @param from zh-CN

 * @param to  en

 * @return String

 * @throws Exception

 */

public static String doGoogleTranslate(String query,String from,String to)throws Exception{

        String url = "https://translate.google.com.hk/translate_a/single?";

        String urlParam ="client=t&sl="+from+"&tl="+to+"&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&source=btn&ssel=0&tsel=0&kc=0&tk="+getGgJs(query,getGg())+"&q="+query;

     return ggGetResult(googleTranslate(url+urlParam));

}

/**

 * 封装Goole翻译请求

 * @param url

 * @return String

 * @throws Exception

 */

private static String googleTranslate(String url) throws Exception{

        try {

         URIBuilder uri = new URIBuilder(url);

         HttpGet request = new HttpGet(uri.toString());

request.setHeader("Cookie","NID=511=UKCb40FREknEZtX19ubTXHKnTj2fqh8YZePtu2eWf-ZXdPN_Rs35XiJGF_yjbW2oaSAz4XBJVYOc_2xYAYyQiD3IEoHBJqghUeumnQJdvjn95jqU71b00BtMl2mHwoNiMLYDZgCDBtqU2A5Ql6O3oVMhvGyPrY3CbSsp4kdhzmE; _ga=GA1.3.409789010.1640080107; _gid=GA1.3.27316764.1640080107");

        request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0");

        request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

        request.setHeader("Origin","https://translate.google.com.hk");

        request.setHeader("Referer","https://translate.google.com.hk/");

        request.setHeader("X-Requested-With","XMLHttpRequest");

        CloseableHttpResponse response = httpClient.execute(request);

        HttpEntity entity = response.getEntity();

        String result = EntityUtils.toString(entity, "UTF-8");

        EntityUtils.consume(entity);

        response.getEntity().getContent().close();

        response.close();

        return result;

        } catch (Exception e) {

throw e;

}

}

/**

 * 处理谷歌翻译结果

 * @param json

 * @return

 */

@SuppressWarnings({"rawtypes", "unused" })

private static String ggGetResult(String json){

        List result = JSON.parseObject(json, List.class);

        if(!result.isEmpty()){

                return ((List)((List)result.get(0)).get(0)).get(0)+"";

        }

        return null;

}

/**

 * 加载js获取签名信息

 * @param query

 * @param js

 * @return

 */

private static String getGgJs(String query,String js){

     String res = null;

     try {

      ScriptEngine bdToken = new ScriptEngineManager().getEngineByName("js");

          bdToken.eval(js);

          Invocable inv2 = (Invocable) bdToken;

          res =(String)inv2.invokeFunction("sig",query);

        } catch (Exception e) {

         res = null;

        }

     return res;

    }

    

   

    /**

     * google 签名 JS

     * @return String

     */

private static String getGg(){

     StringBuffer gg = new StringBuffer();

     gg.append("var sig = function sig(a) {                                                                                                                                                                                                                                                                                                                                          ");

gg.append("    var k = '';                                                                                                                                                                                                                                                                                                                                              ");

gg.append("    var b = 406644;                                                                                                                                                                                                                                                                                                                                          ");

gg.append("    var b1 = 3293161072;                                                                                                                                                                                                                                                                                                                                     ");

gg.append("                                                                                                                                                                                                                                                                                                                                                             ");

gg.append("    var jd = '.';                                                                                                                                                                                                                                                                                                                                            ");

gg.append("    var sb = '+-a^+6';                                                                                                                                                                                                                                                                                                                                       ");

gg.append("    var Zb = '+-3^+b+-f';                                                                                                                                                                                                                                                                                                                                    ");

gg.append("                                                                                                                                                                                                                                                                                                                                                             ");

gg.append("    for (var e = [], f = 0, g = 0; g < a.length; g++) {                                                                                                                                                                                                                                                                                                      ");

gg.append("        var m = a.charCodeAt(g);                                                                                                                                                                                                                                                                                                                             ");

gg.append("        128 > m ? e[f++] = m: (2048 > m ? e[f++] = m >> 6 | 192 : (55296 == (m & 64512) && g + 1 < a.length && 56320 == (a.charCodeAt(g + 1) & 64512) ? (m = 65536 + ((m & 1023) << 10) + (a.charCodeAt(++g) & 1023), e[f++] = m >> 18 | 240, e[f++] = m >> 12 & 63 | 128) : e[f++] = m >> 12 | 224, e[f++] = m >> 6 & 63 | 128), e[f++] = m & 63 | 128)     ");

gg.append("    }                                                                                                                                                                                                                                                                                                                                                        ");

gg.append("    a = b;                                                                                                                                                                                                                                                                                                                                                   ");

gg.append("    for (f = 0; f < e.length; f++) a += e[f],                                                                                                                                                                                                                                                                                                                ");

gg.append("    a = RL(a, sb);                                                                                                                                                                                                                                                                                                                                           ");

gg.append("    a = RL(a, Zb);                                                                                                                                                                                                                                                                                                                                           ");

gg.append("    a ^= b1 || 0;                                                                                                                                                                                                                                                                                                                                            ");

gg.append("    0 > a && (a = (a & 2147483647) + 2147483648);                                                                                                                                                                                                                                                                                                            ");

gg.append("    a %= 1E6;                                                                                                                                                                                                                                                                                                                                                ");

gg.append("    return a.toString() + jd + (a ^ b)                                                                                                                                                                                                                                                                                                                       ");

gg.append("};                                                                                                                                                                                                                                                                                                                                                           ");

gg.append("                                                                                                                                                                                                                                                                                                                                                             ");

gg.append("function RL(a, b) {                                                                                                                                                                                                                                                                                                                                          ");

gg.append("    var t = 'a';                                                                                                                                                                                                                                                                                                                                             ");

gg.append("    var Yb = '+';                                                                                                                                                                                                                                                                                                                                            ");

gg.append("    for (var c = 0; c < b.length - 2; c += 3) {                                                                                                                                                                                                                                                                                                              ");

gg.append("        var d = b.charAt(c + 2),                                                                                                                                                                                                                                                                                                                             ");

gg.append("        d = d >= t ? d.charCodeAt(0) - 87 : Number(d),                                                                                                                                                                                                                                                                                                       ");

gg.append("        d = b.charAt(c + 1) == Yb ? a >>> d: a << d;                                                                                                                                                                                                                                                                                                         ");

gg.append("        a = b.charAt(c) == Yb ? a + d & 4294967295 : a ^ d                                                                                                                                                                                                                                                                                                   ");

gg.append("    }                                                                                                                                                                                                                                                                                                                                                        ");

gg.append("    return a                                                                                                                                                                                                                                                                                                                                                 ");

gg.append("}                                                                                                                                                                                                                                                                                                                                                            ");                       

        return gg.toString();

    }

}

运行结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/382476.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

OpenWrt 为软件包和docker空间扩容

参考资料 【openwrt折腾日记】解决openwrt固件刷入后磁盘空间默认小的问题&#xff0c;关联openwrt磁盘扩容空间扩容【openwrt分区扩容】轻松解决空间可用不足的尴尬丨老李一瓶奶油的YouTube 划分空间 参考一瓶奶油的YouTube 系统 -> 磁盘管理 -> 磁盘 -> 修改 格…

axios请求大全

本文讲解axios封装方式以及针对各种后台接口的请求方式 axios的介绍和基础配置可以看这个文档: 起步 | Axios中文文档 | Axios中文网 axios的封装 axios封装的重点有三个&#xff0c;一是设置全局config,比如请求的基础路径&#xff0c;超时时间等&#xff0c;第二点是在每次…

SQL labs-SQL注入(二)

环境搭建参考 SQL注入&#xff08;一&#xff09; 一&#xff0c;SQL labs-less2。 http://192.168.61.206:8001/Less-2/?id-1 union select 1,2,group_concat(username , password) from users-- 与第一关没什么太大的不同&#xff0c;唯一区别就是闭合方式为数字型。 二…

【ffmpeg命令入门】ffplay常用命令

文章目录 前言ffplay的简介FFplay 的基本用法常用参数及其作用示例 效果演示图播放普通视频播放网络媒体流RTSP 总结 前言 FFplay 是 FFmpeg 套件中的一个强大的媒体播放器&#xff0c;它基于命令行接口&#xff0c;允许用户以灵活且高效的方式播放音频和视频文件。作为一个简…

系统架构设计师教程 第4章 信息安全技术基础知识-4.3 信息安全系统的组成框架4.4 信息加解密技术-解读

系统架构设计师教程 第4章 信息安全技术基础知识-4.3 信息安全系统的组成框架 4.3 信息安全系统的组成框架4.3.1 技术体系4.3.1.1 基础安全设备4.3.1.2 计算机网络安全4.3.1.3 操作系统安全4.3.1.4 数据库安全4.3.1.5 终端安全设备4.3.2 组织机构体系4.3.3 管理体系4.4 信息加…

使用 Socket和动态代理以及反射 实现一个简易的 RPC 调用

使用 Socket、动态代理、反射 实现一个简易的 RPC 调用 我们前面有一篇 socket 的文章&#xff0c;再之前&#xff0c;还有一篇 java动态代理的文章&#xff0c;本文用到了那两篇文章中的知识点&#xff0c;需要的话可以回顾一下。 下面正文开始&#xff1a; 我们的背景是一个…

CSS实现的扫光效果组件

theme: lilsnake 图片和内容如有侵权&#xff0c;及时与我联系~ 详细内容与注释&#xff1a; CSS实现的扫光效果组件 代码 技术栈与框架 Vue3 CSS 扫光效果的原理 扫光效果的原理就是从左到右无限循环的一个位移动画 实现方式 适配文字扫光效果的css .shark-box { …

【devops】gitlab 实现cicd 实践

本站以分享各种运维经验和运维所需要的技能为主 《python零基础入门》&#xff1a;python零基础入门学习 《python运维脚本》&#xff1a; python运维脚本实践 《shell》&#xff1a;shell学习 《terraform》持续更新中&#xff1a;terraform_Aws学习零基础入门到最佳实战 《k8…

npm 安装报错(已解决)+ 运行 “wue-cli-service”不是内部或外部命令,也不是可运行的程序(已解决)

首先先说一下我这个项目是3年前的一个项目了&#xff0c;中间也是经过了多个人的修改惨咋了布置多少个人的思想&#xff0c;这这道我手里直接npm都安装不上&#xff0c;在网上也查询了多种方法&#xff0c;终于是找到问题所在了 问题1&#xff1a; 先是npm i 报错在下面图片&…

海康视频WEB插件

引入相关依赖 index.html <script src"/video/web-control_1.2.5.min.js"></script> <script src"/video/jquery-1.12.4.min.js" type"text/javascript"></script> <script src"/video/jsencrypt.min.js" …

嵌入式C/C++、FreeRTOS、STM32F407VGT6和TCP:智能家居安防系统的全流程介绍(代码示例)

1. 项目概述 随着物联网技术的快速发展,智能家居安防系统越来越受到人们的重视。本文介绍了一种基于STM32单片机的嵌入式安防中控系统的设计与实现方案。该系统集成了多种传感器,实现了实时监控、报警和远程控制等功能,为用户提供了一个安全、可靠的家居安防解决方案。 1.1 系…

【深度学习】LLaMA-Factory 大模型微调工具, 大模型GLM-4-9B Chat ,微调与部署 (2)

资料&#xff1a; https://github.com/hiyouga/LLaMA-Factory/blob/main/README_zh.md https://www.53ai.com/news/qianyanjishu/2015.html 代码拉取&#xff1a; git clone https://github.com/hiyouga/LLaMA-Factory.git cd LLaMA-Factorybuild镜像和执行镜像&#xff1a; …

“机器说人话”-AI 时代的物联网

万物互联的物联网愿景已经提了许多年了&#xff0c;但是实际效果并不理想&#xff0c;除了某些厂商自己的产品生态中的产品实现了互联之外&#xff0c;就连手机控制空调&#xff0c;电视机和调光灯都没有实现。感觉小米做的好一点&#xff0c;而华为的鸿蒙的全场景&#xff0c;…

【云原生】Kubernetes 中的 PV 和 PVC 介绍、原理、用法及实战案例分析

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

nginx漏洞修复 ngx_http_mp4_module漏洞(CVE-2022-41742)【低可信】 nginx版本升级

风险描述&#xff1a; Nginx 是一款轻量级的Web服务器、反向代理服务器。 Nginx 的受影响版本中的ngx _http_mp4_module模块存在内存越界写入漏洞&#xff0c;当在配置中使用 mp4 directive时&#xff0c;攻击者可利用此漏洞使用使用ngx_http_mp4_module模块处理特制的音频或视…

Hive分布式SQL计算平台

Hive分布式SQL计算平台 一、Hive 概述二、Hive架构三、Hive客户端 1、Hive有哪些客户端可以使用2、Hive第三方客户端 四、Hive使用语法 1、数据库操作2、内部表&#xff0c;外部表3、数据的导入与导出4、分区表5、分桶表6、复杂类型操作7、数据抽样8、Virtual Columns 虚拟列9…

springboot 项目整合 AI (文心一言)

百度智能云网址&#xff1a;https://cloud.baidu.com/?fromconsole 注册——个人认证——登录成功 第一步&#xff1a;点击千帆大模型平台 ​ 第二步&#xff1a;点击应用接入——创建应用 ​ 第三步&#xff1a;点击接口文档——API列表——可以点击指定模型进行查看调…

Spring Boot集成Activity7实现简单的审批流

由于客户对于系统里的一些新增数据&#xff0c;例如照片墙、照片等&#xff0c;想实现上级逐级审批通过才可见的效果&#xff0c;于是引入了Acitivity7工作流技术来实现&#xff0c;本文是对实现过程的介绍讲解&#xff0c;由于我是中途交接前同事的这块需求&#xff0c;所以具…

DolphinDB Web 端权限管理:可视化操作指南

在现代数据库管理中&#xff0c;高效和直观的权限管理对于用户的数据安全是至关重要的。过去 DolphinDB 用户需要依赖系统脚本来管理用户和权限&#xff0c;这对于缺乏技术背景的管理员来说既复杂又容易出错。 为了提升用户体验和操作效率&#xff0c;DolphinDB 目前在 Web 上…

【ACM出版】2024集成电路设计与集成系统国际研讨会(ICDIS2024)

会议日期&#xff1a;2024年11月22-24日 会议地点&#xff1a;中国-厦门 会议官网&#xff1a;https://www.iaast.cn/meet/home/Bx122dOo 【大会主席】 Sri Niwas Singh&#xff0c;印度信息技术与管理研究所 【主讲嘉宾】 【论文出版与检索】 大会即日起围绕主题征集会…