爱词霸翻译接口 破解

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hujingshuang/article/details/80190980

前面分别介绍了《有道翻译接口 破解》《谷歌翻译接口 破解》《百度翻译接口 破解》及《腾讯翻译接口 破解》,下面来尝试一下金山爱词霸翻译接口(Github项目地址,欢迎star)。
我们来看一下爱词霸的页面分析,如下图:
审查元素
可知 Request URL 和 Request Method,接着往下看:
审查元素
我们发现,爱词霸的参数比较少且简单,并没有涉及 token 之类的加密认证,所以猜测会比较简单。那么就直接上代码来验证一下,模拟发起 http 请求。

public class Iciba {
    public static void main(String[] args) throws Exception {
        String form = "zh";
        String to = "en";
        String q = "我要妹子!";
        String url = "http://fy.iciba.com/ajax.php?a=fy";

        Map<String, String> params = new HashMap<>();
        params.put("f", form);
        params.put("t", to);
        params.put("w", q);

        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPost request = new HttpPost(util.getUrlWithQueryString(url, params));
        CloseableHttpResponse response = httpClient.execute(request);

        HttpEntity entity = response.getEntity();

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

        System.out.println(result);
        EntityUtils.consume(entity);

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

果然,直接就可以得到结果了,返回的结果为 json 字符串格式,需要自己处理一下提取到结果,这里就不展开了。

猜你喜欢

转载自blog.csdn.net/hujingshuang/article/details/80190980