How can I use http://translate.google.com/ to translate the string in Java program?

前端 未结 4 1773
庸人自扰
庸人自扰 2021-01-29 01:18

I want to use http://translate.google.com/ to translate the string. And now I want to sent a string from a java program in http://translate.google.com/ to translate the string f

4条回答
  •  梦如初夏
    2021-01-29 02:05

    The wrong way to do that : use an HTTPClient to emulate, in Java, a browser request. It's a bad way of using a website, as you'll make dirty things in HTTP, and your program will have to be modified each time Google modify the HTML pages on translate.google.com (even if that should be pretty rare).

    The right way of doing that : use the Google Translate API provided by Google for that purpose. It's just a REST service so it works quite easily in JAVA.

    Beware that the number of translations that you can do each day is, as far as i remember, limited to a certain amount each day (check the online conditions on the API website). At first glance after just checking that, it seems that the v2 API is not free anymore, i don't know if you can stick to the v1 one.

提交回复
热议问题